aboutsummaryrefslogtreecommitdiff
path: root/gdb/completer.c
diff options
context:
space:
mode:
authorJan Vrany <jan.vrany@fit.cvut.cz>2019-05-30 13:04:26 +0100
committerJan Vrany <jan.vrany@fit.cvut.cz>2019-05-30 13:05:40 +0100
commit0ef209f22c24b9243de68c35c576f7111198f915 (patch)
tree01983da66876332cfaea7f1d650360aa25a78bde /gdb/completer.c
parente3f56a99f66298bb505d0426950b9716a853a5df (diff)
downloadgdb-0ef209f22c24b9243de68c35c576f7111198f915.zip
gdb-0ef209f22c24b9243de68c35c576f7111198f915.tar.gz
gdb-0ef209f22c24b9243de68c35c576f7111198f915.tar.bz2
Initialize variable word in complete
The complete function should set parameter word to the end of the word to complete. However, completion_find_completion_word may fail, leaving word uninitialized. To make sure word is always set, initialize it to the completion point which is the end of the line parameter. gdb/Changelog PR cli/24587 * completer.c (complete): Initialize variable word.
Diffstat (limited to 'gdb/completer.c')
-rw-r--r--gdb/completer.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/gdb/completer.c b/gdb/completer.c
index cc2f80b..24c8446 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -1622,6 +1622,13 @@ complete (const char *line, char const **word, int *quote_char)
completion_tracker tracker_handle_completions;
completion_tracker *tracker;
+ /* The WORD should be set to the end of word to complete. We initialize
+ to the completion point which is assumed to be at the end of LINE.
+ This leaves WORD to be initialized to a sensible value in cases
+ completion_find_completion_word() fails i.e., throws an exception.
+ See bug 24587. */
+ *word = line + strlen (line);
+
try
{
*word = completion_find_completion_word (tracker_handle_brkchars,