aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-sh
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2025-04-22 21:43:43 +0100
committerAndrew Burgess <aburgess@redhat.com>2025-04-23 23:50:22 +0100
commit1fc2d1491c0d512c61303f71d2ba420dd389da0f (patch)
treebe071aadd6c894b1ffe68ba48c39d521710ddc87 /ld/testsuite/ld-sh
parentf17820ec6e4326447e1de02b5211793290cd32ef (diff)
downloadbinutils-master.zip
binutils-master.tar.gz
binutils-master.tar.bz2
gdb/python: don't use PyObject_IsInstance in py-registers.cHEADmaster
In python/py-registers.c we make use of PyObject_IsInstance. The PyObject_IsInstance can return -1 for an error, 0 for false, or 1 for true. In py-registers.c we treat the return value from PyObject_IsInstance as a boolean, which means both -1 and 1 will be treated as true. If PyObject_IsInstance returns -1 for an error, this will be treated as true, we will then invoke undefined behaviour as the pyo_reg_id object will be treated as a gdb.RegisterDescriptor, even though it might not be. I noticed that the gdb.RegisterDescriptor class does not have the Py_TPFLAGS_BASETYPE flag, and therefore cannot be inherited from. As such, using PyObject_IsInstance is not necessary, we can use PyObject_TypeCheck instead. The PyObject_TypeCheck function only returns 0 or 1, so we don't need to worry about the error case. Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'ld/testsuite/ld-sh')
0 files changed, 0 insertions, 0 deletions