diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 32c5558dc88..24e5eb4f922 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2013-05-21 Pedro Alves + + * 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. + 2013-05-21 Pedro Alves * python/py-utils.c (py_decref): Remove extra braces. diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c index 8c45cd6a6fa..8fa2f425f78 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. */ diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c index 80bacf76626..7c7c5caee9b 100644 --- a/gdb/python/py-utils.c +++ b/gdb/python/py-utils.c @@ -31,8 +31,7 @@ py_decref (void *p) { PyObject *py = p; - if (py) - Py_DECREF (py); + Py_DECREF (py); } /* Return a new cleanup which will decrement the Python object's