]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
2007-08-01 Michael Snyder <msnyder@access-company.com>
authorMichael Snyder <msnyder@vmware.com>
Wed, 1 Aug 2007 20:26:31 +0000 (20:26 +0000)
committerMichael Snyder <msnyder@vmware.com>
Wed, 1 Aug 2007 20:26:31 +0000 (20:26 +0000)
* cli/cli-decode.c (lookup_cmd): Check for null earlier, to
avoid dereference in lookup_cmd_1.

gdb/ChangeLog
gdb/cli/cli-decode.c

index b6ec94ae2b060dfc713bc0d3a5584a90d6825050..7dba67cffdb803592cc29a7d8d07239d85855faa 100644 (file)
@@ -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.
index e7c72c5ba4700fb47d26dedc9040bb23de68887c..6985edd6f0a8af5ae1cf9f869d68a6277c8378f2 100644 (file)
@@ -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;