diff options
author | Pedro Alves <palves@redhat.com> | 2013-05-21 20:53:21 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2013-05-21 20:53:21 +0000 |
commit | c8c735b96348ead98a7ddeb25a5eed4912586396 (patch) | |
tree | 7b60b5ecb7cedf471fa2f927fce6cea0a4e92693 /gdb/python/py-prettyprint.c | |
parent | 1915daebe6683fb1cdd42c87a6db5532a396bbc6 (diff) |
py_decref: Don't check for NULL before calling Py_DECREF.
The only difference between Py_DECREF and Py_XDECREF is that the latter allows passing
in a NULL object, while the former prohibits it. Given that, it's natural to expect
the same from py_decref vs py_xdecref.
gdb/
2013-05-21 Pedro Alves <palves@redhat.com>
* python/py-prettyprint.c (apply_val_pretty_printer): Check
whether PRINTER is NULL before installing a Py_DECREF cleanup.
* python/py-utils.c (py_decref): Don't check for NULL before
calling Py_DECREF.
Diffstat (limited to 'gdb/python/py-prettyprint.c')
-rw-r--r-- | gdb/python/py-prettyprint.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c index 8c45cd6a6f..8fa2f425f7 100644 --- a/gdb/python/py-prettyprint.c +++ b/gdb/python/py-prettyprint.c @@ -735,8 +735,12 @@ apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr, /* Find the constructor. */ printer = find_pretty_printer (val_obj); Py_DECREF (val_obj); + + if (printer == NULL) + goto done; + make_cleanup_py_decref (printer); - if (! printer || printer == Py_None) + if (printer == Py_None) goto done; /* If we are printing a map, we want some special formatting. */ |