mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-05-28 22:21:26 +08:00
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.
This commit is contained in:
@ -1,3 +1,9 @@
|
||||
2018-09-23 Tom Tromey <tom@tromey.com>
|
||||
|
||||
PR python/17284:
|
||||
* python/py-type.c (typy_template_argument): Check for negative
|
||||
argument number.
|
||||
|
||||
2018-09-23 Tom Tromey <tom@tromey.com>
|
||||
|
||||
PR python/14062:
|
||||
|
@ -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);
|
||||
|
@ -1,3 +1,9 @@
|
||||
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.
|
||||
|
||||
2018-09-23 Tom Tromey <tom@tromey.com>
|
||||
|
||||
PR python/14062:
|
||||
|
@ -54,6 +54,10 @@ proc test_template_arg {exefile type} {
|
||||
# Replace '*' with '\*' in regex.
|
||||
regsub -all {\*} $type {\*} t
|
||||
gdb_test "python print (foo.type.template_argument(0))" $t $type
|
||||
|
||||
gdb_test "python print(foo.type.template_argument(-1))" \
|
||||
"Template argument number must be non-negative\r\nError while executing Python code." \
|
||||
"negative template argument number"
|
||||
}
|
||||
|
||||
test_template_arg "${binfile}-ci" "const int"
|
||||
|
Reference in New Issue
Block a user