summaryrefslogtreecommitdiff
path: root/gdb/cli
diff options
context:
space:
mode:
authorMichael Snyder <msnyder@specifix.com>2007-08-01 20:26:31 +0000
committerMichael Snyder <msnyder@specifix.com>2007-08-01 20:26:31 +0000
commit69d1fe41fbdba2990b33af35c51420596deec06c (patch)
treee220edac550b264c93b20a59c360d6ee8e918b66 /gdb/cli
parenta6bfc1195fe500fe57025057717bc047bdbd2638 (diff)
downloadgdb-69d1fe41fbdba2990b33af35c51420596deec06c.tar.gz
2007-08-01 Michael Snyder <msnyder@access-company.com>
* cli/cli-decode.c (lookup_cmd): Check for null earlier, to avoid dereference in lookup_cmd_1.
Diffstat (limited to 'gdb/cli')
-rw-r--r--gdb/cli/cli-decode.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index e7c72c5ba47..6985edd6f0a 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -1226,28 +1226,27 @@ lookup_cmd (char **line, struct cmd_list_element *list, char *cmdtype,
int allow_unknown, int ignore_help_classes)
{
struct cmd_list_element *last_list = 0;
- struct cmd_list_element *c =
- lookup_cmd_1 (line, list, &last_list, ignore_help_classes);
+ struct cmd_list_element *c;
/* Note: Do not remove trailing whitespace here because this
would be wrong for complete_command. Jim Kingdon */
+ if (!*line)
+ error (_("Lack of needed %scommand"), cmdtype);
+
+ c = lookup_cmd_1 (line, list, &last_list, ignore_help_classes);
+
if (!c)
{
if (!allow_unknown)
{
- if (!*line)
- error (_("Lack of needed %scommand"), cmdtype);
- else
- {
- char *q;
- int len = find_command_name_length (*line);
+ char *q;
+ int len = find_command_name_length (*line);
- q = (char *) alloca (len + 1);
- strncpy (q, *line, len);
- q[len] = '\0';
- undef_cmd_error (cmdtype, q);
- }
+ q = (char *) alloca (len + 1);
+ strncpy (q, *line, len);
+ q[len] = '\0';
+ undef_cmd_error (cmdtype, q);
}
else
return 0;