Hannes pointed out that gdb.execute_mi() will crash.
This patch fixes the bug.
Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
if (n_args < 0)
return nullptr;
+ if (n_args == 0)
+ {
+ PyErr_SetString (PyExc_TypeError,
+ _("gdb.execute_mi requires command argument"));
+ return nullptr;
+ }
+
for (Py_ssize_t i = 0; i < n_args; ++i)
{
/* Note this returns a borrowed reference. */
"set arguments"
gdb_test "show args" ".*\"a b c\"."
+
+# Ensure that this causes an error, not a crash.
+gdb_test "python gdb.execute_mi()" \
+ "Error occurred in Python: gdb.execute_mi requires command argument"