aboutsummaryrefslogtreecommitdiff
path: root/gdb/tui/tui-source.c
diff options
context:
space:
mode:
authorPatrick Palka <patrick@parcs.ath.cx>2015-04-25 10:29:29 -0400
committerPatrick Palka <patrick@parcs.ath.cx>2015-04-27 21:19:58 -0400
commit2eb639cbe4baa33545ca008d6054ea5db1d8f6a8 (patch)
tree75913443c4e5dade016d08610cded0bd1451ae2b /gdb/tui/tui-source.c
parent9720679936fc4f710d718f13d903c7826e048a36 (diff)
downloadbinutils-2eb639cbe4baa33545ca008d6054ea5db1d8f6a8.zip
binutils-2eb639cbe4baa33545ca008d6054ea5db1d8f6a8.tar.gz
binutils-2eb639cbe4baa33545ca008d6054ea5db1d8f6a8.tar.bz2
TUI: avoid calling strcpy() on identical string objects
In tui_set_source_content(), when offset == 0 the source and destination pointers of the call to strcpy() are actually the same. In this case not only is strcpy() unnecessary but it is also UB when the two strings overlap. gdb/ChangeLog: * tui/tui-source.c (tui_set_source_content): Avoid calling strcpy() when offset is 0.
Diffstat (limited to 'gdb/tui/tui-source.c')
-rw-r--r--gdb/tui/tui-source.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index 31df0c8..018a1df 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -218,7 +218,9 @@ tui_set_source_content (struct symtab *s,
}
/* Now copy the line taking the offset into
account. */
- if (strlen (src_line) > offset)
+ if (offset == 0)
+ ;
+ else if (strlen (src_line) > offset)
strcpy (TUI_SRC_WIN->generic.content[cur_line]
->which_element.source.line,
&src_line[offset]);