This is the mail archive of the gdb-testers@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Use xstrdup in tui_set_source_content


*** TEST RESULTS FOR COMMIT 986041cda76a312e4285c9ba1e51b1778fcb15ce ***

Author: Tom Tromey <tom@tromey.com>
Branch: master
Commit: 986041cda76a312e4285c9ba1e51b1778fcb15ce

Use xstrdup in tui_set_source_content

valgrind pointed out that the string copy in tui_set_source_content
was not allocating space for the trailing \0:

==3941== Invalid write of size 1
==3941==    at 0x4C3239F: strcpy (vg_replace_strmem.c:512)
==3941==    by 0x72036B: strcpy (string_fortified.h:90)
==3941==    by 0x72036B: tui_set_source_content(symtab*, int, int) (tui-source.c:203)

Looking closer, I don't think there's a need to check the line width
here, so this patch changes it to use xstrdup.

Tested by re-running the TUI under valgrind.  There are still other
valgrind reports from TUI code, but this one is gone.

gdb/ChangeLog
2019-01-03  Tom Tromey  <tom@tromey.com>

	* tui/tui-source.c (tui_set_source_content): Use xstrdup.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]