aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-09-15 00:29:20 -0600
committerTom Tromey <tom@tromey.com>2018-09-23 23:15:12 -0600
commitfd3ba736db19d4c7cd928f3735329339a8c8ef47 (patch)
tree4e9f9d7422920505955baf6c7c3b54d8f2ea26cc /gdb/python
parent39a24317ac65837663ce1e1b0adcf880758ddc8e (diff)
downloadgdb-fd3ba736db19d4c7cd928f3735329339a8c8ef47.zip
gdb-fd3ba736db19d4c7cd928f3735329339a8c8ef47.tar.gz
gdb-fd3ba736db19d4c7cd928f3735329339a8c8ef47.tar.bz2
Check for negative argument in Type.template_argument
typy_template_argument did not check if the template argument was non-negative. A negative value could cause a gdb crash. 2018-09-23 Tom Tromey <tom@tromey.com> PR python/17284: * python/py-type.c (typy_template_argument): Check for negative argument number. gdb/testsuite/ChangeLog 2018-09-23 Tom Tromey <tom@tromey.com> PR python/17284: * gdb.python/py-template.exp (test_template_arg): Add test for negative template argument number.
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/py-type.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index c7cad2e..897ad93 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -930,6 +930,13 @@ typy_template_argument (PyObject *self, PyObject *args)
if (! PyArg_ParseTuple (args, "i|O", &argno, &block_obj))
return NULL;
+ if (argno < 0)
+ {
+ PyErr_SetString (PyExc_RuntimeError,
+ _("Template argument number must be non-negative"));
+ return NULL;
+ }
+
if (block_obj)
{
block = block_object_to_block (block_obj);