diff options
author | Michael Snyder <msnyder@vmware.com> | 2007-08-01 20:26:31 +0000 |
---|---|---|
committer | Michael Snyder <msnyder@vmware.com> | 2007-08-01 20:26:31 +0000 |
commit | 3cebf8d88289a3e28abfad8f3f811efd012850b0 (patch) | |
tree | 0533f0a43760bcaaeaf691b270386977f03ce0d5 | |
parent | c0645fb52f4a0e374e94ead66a060980b9151907 (diff) | |
download | gdb-3cebf8d88289a3e28abfad8f3f811efd012850b0.zip gdb-3cebf8d88289a3e28abfad8f3f811efd012850b0.tar.gz gdb-3cebf8d88289a3e28abfad8f3f811efd012850b0.tar.bz2 |
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.
-rw-r--r-- | gdb/ChangeLog | 3 | ||||
-rw-r--r-- | gdb/cli/cli-decode.c | 25 |
2 files changed, 15 insertions, 13 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b6ec94a..7dba67c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,8 @@ 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. + * tui/tui-data.c (tui_alloc_content): Move assign out of if, clean up long lines. (tui_alloc_generic_win_info): Tidy by using XMALLOC macro. diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index e7c72c5..6985edd 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; |