diff options
author | Tom Tromey <tom@tromey.com> | 2019-11-17 15:50:31 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019-12-01 12:29:50 -0700 |
commit | 517d261dfafb7e5317b841b01ab853a76deb8128 (patch) | |
tree | 5a020ab66a099aa1209b5b2bf26ba95e28773f36 /gdb/tui/tui-winsource.c | |
parent | 484c9b643c206edf636d15aad1cf618e515350b7 (diff) | |
download | gdb-517d261dfafb7e5317b841b01ab853a76deb8128.zip gdb-517d261dfafb7e5317b841b01ab853a76deb8128.tar.gz gdb-517d261dfafb7e5317b841b01ab853a76deb8128.tar.bz2 |
Fix latent bug in tui_copy_source_line
tui_copy_source_line has a bug, where it can advance past the
terminating \0 in its input string. This patch fixes the bug and adds
a test case for this function.
gdb/ChangeLog
2019-12-01 Tom Tromey <tom@tromey.com>
* tui/tui-winsource.c (tui_copy_source_line): Don't advance past
\0.
* unittests/tui-selftests.c: New file.
* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add tui-selftests.c.
Change-Id: I46cdabe6e57549983149b8f640cda5edd16fa260
Diffstat (limited to 'gdb/tui/tui-winsource.c')
-rw-r--r-- | gdb/tui/tui-winsource.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index 81937c1..6653709 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -103,6 +103,8 @@ tui_copy_source_line (const char **ptr, int line_no, int first_col, lineptr += skip_bytes; continue; } + if (c == '\0') + break; ++lineptr; ++column; |