diff options
| author | Andrew Burgess <aburgess@redhat.com> | 2025-08-21 12:43:58 +0100 |
|---|---|---|
| committer | Andrew Burgess <aburgess@redhat.com> | 2025-08-28 15:51:16 +0100 |
| commit | 8d9a7d8914f29d4b0621c09e303af4a84042fd9e (patch) | |
| tree | 659c9b6b5174d4cca93e97634d7abb6ce98bcdf0 /gdb/python/python.c | |
| parent | 69b9f23264b1c9156f9499125df96c69e9927f14 (diff) | |
| download | binutils-8d9a7d8914f29d4b0621c09e303af4a84042fd9e.zip binutils-8d9a7d8914f29d4b0621c09e303af4a84042fd9e.tar.gz binutils-8d9a7d8914f29d4b0621c09e303af4a84042fd9e.tar.bz2 | |
gdb/python: check return from final PyObject_New in py-disasm.c
In this commit:
commit dbd05b9edcf760a7001985f89bc760358a3c19d7
Date: Wed Aug 20 10:45:09 2025 +0100
gdb/python: check return value of PyObject_New in all cases
I missed a call to PyObject_New in python/py-disasm.c, which this
commit addresses.
Unlike the previous commit, the call to PyObject_New in py-disasm.c is
contained within the scoped_disasm_info_object class, which makes it
harder to check for NULL and return.
So in this commit I've rewritten the scoped_disasm_info_object class,
moving the call to PyObject_New out into gdbpy_print_insn, which is
the only place that scoped_disasm_info_object was being used.
As scoped_disasm_info_object is no longer responsible for creating the
underlying Python object, I figured that I might as well move the
initialisation of that object out of scoped_disasm_info_object too.
With that done, the scoped_disasm_info_object now has just one task,
invalidating the existing disasm_info_object at the end of the scope.
So I renamed scoped_disasm_info_object to
scoped_invalidate_disasm_info, which reflects its only task.
I made a couple of other small adjustments that were requested during
review, these are both in the same code area: updating
disasm_info_fill to take an object reference rather than a pointer,
and removing the local variable insn_disas_obj from gdbpy_print_insn,
and inline its value at the one place it was used.
There should be no user visible changes after this commit. Except for
the PyObject_New call, which now has proper error checking. But in
the working case, nothing should have changed.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Diffstat (limited to 'gdb/python/python.c')
0 files changed, 0 insertions, 0 deletions
