Fix nullptr in with_command_1
authorPedro Alves <palves@redhat.com>
Wed, 21 Aug 2019 20:11:33 +0000 (21:11 +0100)
committerPedro Alves <palves@redhat.com>
Wed, 21 Aug 2019 20:11:33 +0000 (21:11 +0100)
Running 'with' without arguments crashes GDB.  This fixes it.

gdb/ChangeLog:
2019-08-21  Bogdan Harjoc  <harjoc@gmail.com>

* cli/cli-cmds.c (with_command_1): Error out if no arguments.

gdb/testsuite/ChangeLog:
2019-08-21  Pedro Alves  <palves@redhat.com>

* gdb.base/with.exp: Test "with" with no arguments.

gdb/ChangeLog
gdb/cli/cli-cmds.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/with.exp

index 01e60fb18944ec0e544e129681cb1ab422d81ded..966bfb7d9fcb273fde957fbcfa4ed3efde4c3dfb 100644 (file)
@@ -1,3 +1,7 @@
+2019-08-21  Bogdan Harjoc  <harjoc@gmail.com>
+
+       * cli/cli-cmds.c (with_command_1): Error out if no arguments.
+
 2019-08-21  Christian Biesinger  <cbiesinger@google.com>
 
        * tui/tui-data.h (tui_gen_win_info): Add an =default
index 30e0958b60b7d48cb4fa89b3dc853b588e5dcf41..4fc656775c9bb40e86133a53f6312ea58db8d270 100644 (file)
@@ -217,6 +217,9 @@ void
 with_command_1 (const char *set_cmd_prefix,
                cmd_list_element *setlist, const char *args, int from_tty)
 {
+  if (args == nullptr)
+    error (_("Missing arguments."));
+
   const char *delim = strstr (args, "--");
   const char *nested_cmd = nullptr;
 
index 7fea9cd0712d23b138b6cade4902054f1b25f37d..e56cc16628d070e28cdf49d3391f8370d02d6c62 100644 (file)
@@ -1,3 +1,7 @@
+2019-08-21  Pedro Alves  <palves@redhat.com>
+
+       * gdb.base/with.exp: Test "with" with no arguments.
+
 2019-08-21  Tom de Vries  <tdevries@suse.de>
 
        * gdb.base/gdb-caching-proc.exp: Sort files.
index 9ea768563a3efc7f4d91fdc73a37252813ed89af..a972296d78fc241f82fea6be79584e64dbeedde4 100644 (file)
@@ -220,6 +220,8 @@ with_test_prefix "run control" {
 
 # Check errors.
 with_test_prefix "errors" {
+    gdb_test "with" "Missing arguments\\."
+
     # Try both an unknown root setting and an unknown prefixed
     # setting.  The errors come from different locations in the
     # sources.
This page took 0.034877 seconds and 4 git commands to generate.