mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-05-24 10:46:24 +08:00
2009-09-21 Phil Muldoon <pmuldoon@redhat.com>
* python/py-value.c (valpy_getitem): Test value before allowing subscript operation. 2009-09-21 Phil Muldoon <pmuldoon@redhat.com> * gdb.python/py-value.exp (test_subscript_regression): New function. Test for invalid subscripts. * gdb.python/py-value.c (main): Add test array, and pointer to it. (ptr_ref): New function.
This commit is contained in:
@ -324,7 +324,18 @@ valpy_getitem (PyObject *self, PyObject *key)
|
||||
type. */
|
||||
struct value *idx = convert_value_from_python (key);
|
||||
if (idx != NULL)
|
||||
res_val = value_subscript (tmp, value_as_long (idx));
|
||||
{
|
||||
/* Check the value's type is something that can be accessed via
|
||||
a subscript. */
|
||||
struct type *type;
|
||||
tmp = coerce_ref (tmp);
|
||||
type = check_typedef (value_type (tmp));
|
||||
if (TYPE_CODE (type) != TYPE_CODE_ARRAY
|
||||
&& TYPE_CODE (type) != TYPE_CODE_PTR)
|
||||
error( _("Cannot subscript requested type"));
|
||||
else
|
||||
res_val = value_subscript (tmp, value_as_long (idx));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user