From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org, Pedro Alves <palves@redhat.com>,
Jan Vrany <jan.vrany@fit.cvut.cz>
Subject: [committed][gdb/cli] Fix use of uninitialized variable in complete_command
Date: Tue, 21 May 2019 14:36:00 -0000 [thread overview]
Message-ID: <20190521143632.GA21040@delia> (raw)
Hi,
When building gdb on ubuntu 16.04 with gcc 5.4.0, and running the gdb
testsuite we run into:
...
FAIL: gdb.linespec/explicit.exp: complete after -line: \
cmd complete "b -line argument " (timeout)
...
The failure is reproducible outside the testsuite like this:
...
$ gdb -q build/gdb/testsuite/outputs/gdb.linespec/explicit/explicit \
-ex "complete b -line argument"
Reading symbols from \
build/gdb/testsuite/outputs/gdb.linespec/explicit/explicit...
terminate called after throwing an instance of 'std::length_error'
what(): basic_string::_M_create
Aborted (core dumped)
...
The problem is here in complete_command:
...
completion_result result = complete (arg, &word, "e_char);
std::string arg_prefix (arg, word - arg);
if (result.number_matches != 0)
...
The problem is that the word variable is not initialized when
result.number_matches == 0, but the variable is still used in the arg_prefix
initialization.
Fix this by guarding the arg_prefix initialization with the
'result.number_matches != 0' test.
Build and tested on x86_64-linux.
Committed to trunk.
Thanks,
- Tom
[gdb/cli] Fix use of uninitialized variable in complete_command
gdb/ChangeLog:
2019-05-21 Tom de Vries <tdevries@suse.de>
PR cli/24587
* cli/cli-cmds.c (complete_command): Fix use of unitialized variable.
---
gdb/cli/cli-cmds.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 332078b910..daf409a558 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -248,10 +248,10 @@ complete_command (const char *arg, int from_tty)
completion_result result = complete (arg, &word, "e_char);
- std::string arg_prefix (arg, word - arg);
-
if (result.number_matches != 0)
{
+ std::string arg_prefix (arg, word - arg);
+
if (result.number_matches == 1)
printf_unfiltered ("%s%s\n", arg_prefix.c_str (), result.match_list[0]);
else
reply other threads:[~2019-05-21 14:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190521143632.GA21040@delia \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
--cc=jan.vrany@fit.cvut.cz \
--cc=palves@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox