diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b706e712f8a..50fc8deb409 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2016-08-19 Yao Qi + + * completer.c (linespec_location_completer): Make file_to_match + null-terminated. + 2016-08-19 Pedro Alves * amd64-tdep.c (amd64_relocate_instruction) : Handle return diff --git a/gdb/completer.c b/gdb/completer.c index 5c3b3fcfaae..d0e6bc80fd1 100644 --- a/gdb/completer.c +++ b/gdb/completer.c @@ -264,7 +264,8 @@ linespec_location_completer (struct cmd_list_element *ignore, char *s; file_to_match = (char *) xmalloc (colon - text + 1); - strncpy (file_to_match, text, colon - text + 1); + strncpy (file_to_match, text, colon - text); + file_to_match[colon - text] = '\0'; /* Remove trailing colons and quotes from the file name. */ for (s = file_to_match + (colon - text); s > file_to_match;