aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/py-prettyprint.c
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2015-04-28 21:53:54 -0700
committerDoug Evans <dje@google.com>2015-04-28 21:53:54 -0700
commit69b4374a87e5029ac4831c7a4471815514df662f (patch)
tree9041be61ebe1e1bd8df326650dd946102f15ae77 /gdb/python/py-prettyprint.c
parent5e7cf0784c9b543b1870b974a78244c40105c523 (diff)
downloadbinutils-69b4374a87e5029ac4831c7a4471815514df662f.zip
binutils-69b4374a87e5029ac4831c7a4471815514df662f.tar.gz
binutils-69b4374a87e5029ac4831c7a4471815514df662f.tar.bz2
PR python/18089
gdb/ChangeLog: PR python/18089 * python/py-prettyprint.c (print_children): Verify result of children iterator. Provide better error message. * python/python-internal..h (gdbpy_print_python_errors_p): Declare. * python/python.c (gdbpy_print_python_errors_p): New function. gdb/testsuite/ChangeLog: * gdb.python/py-bad-printers.c: New file. * gdb.python/py-bad-printers.py: New file. * gdb.python/py-bad-printers.exp: New file.
Diffstat (limited to 'gdb/python/py-prettyprint.c')
-rw-r--r--gdb/python/py-prettyprint.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c
index d8579fa..274ac6c 100644
--- a/gdb/python/py-prettyprint.c
+++ b/gdb/python/py-prettyprint.c
@@ -554,8 +554,22 @@ print_children (PyObject *printer, const char *hint,
break;
}
+ if (! PyTuple_Check (item) || PyTuple_Size (item) != 2)
+ {
+ PyErr_SetString (PyExc_TypeError,
+ _("Result of children iterator not a tuple"
+ " of two elements."));
+ gdbpy_print_stack ();
+ Py_DECREF (item);
+ continue;
+ }
if (! PyArg_ParseTuple (item, "sO", &name, &py_v))
{
+ /* The user won't necessarily get a stack trace here, so provide
+ more context. */
+ if (gdbpy_print_python_errors_p ())
+ fprintf_unfiltered (gdb_stderr,
+ _("Bad result from children iterator.\n"));
gdbpy_print_stack ();
Py_DECREF (item);
continue;