mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-06 15:38:45 +08:00
Fix crash in gdbpy_parse_register_id
I noticed that gdbpy_parse_register_id would assert if passed a Python object of a type it was not expecting. The included test case shows this crash. This patch fixes the problem and also changes gdbpy_parse_register_id to be more "Python-like" -- it always ensures the Python error is set when it fails, and the callers now simply propagate the existing exception.
This commit is contained in:
@ -260,10 +260,7 @@ unwind_infopy_add_saved_register (PyObject *self, PyObject *args)
|
||||
&pyo_reg_id, &pyo_reg_value))
|
||||
return NULL;
|
||||
if (!gdbpy_parse_register_id (pending_frame->gdbarch, pyo_reg_id, ®num))
|
||||
{
|
||||
PyErr_SetString (PyExc_ValueError, "Bad register");
|
||||
return NULL;
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
/* If REGNUM identifies a user register then *maybe* we can convert this
|
||||
to a real (i.e. non-user) register. The maybe qualifier is because we
|
||||
@ -381,10 +378,7 @@ pending_framepy_read_register (PyObject *self, PyObject *args)
|
||||
if (!PyArg_UnpackTuple (args, "read_register", 1, 1, &pyo_reg_id))
|
||||
return NULL;
|
||||
if (!gdbpy_parse_register_id (pending_frame->gdbarch, pyo_reg_id, ®num))
|
||||
{
|
||||
PyErr_SetString (PyExc_ValueError, "Bad register");
|
||||
return NULL;
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
try
|
||||
{
|
||||
|
Reference in New Issue
Block a user