From eefb107a48fd7afea4ea53cf45ea69ae2b227aa0 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Thu, 22 Feb 2001 22:39:18 +0000 Subject: [PATCH] _PyObject_Dump(): If argument is NULL, print "NULL" instead of crashing. --- Objects/object.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Objects/object.c b/Objects/object.c index eff6d7ad07..8a898f8bbf 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -231,9 +231,13 @@ PyObject_Print(PyObject *op, FILE *fp, int flags) /* For debugging convenience. See Misc/gdbinit for some useful gdb hooks */ void _PyObject_Dump(PyObject* op) { - (void)PyObject_Print(op, stderr, 0); - fprintf(stderr, "\nrefcounts: %d\n", op->ob_refcnt); - fprintf(stderr, "address : %p\n", op); + if (op == NULL) + fprintf(stderr, "NULL\n"); + else { + (void)PyObject_Print(op, stderr, 0); + fprintf(stderr, "\nrefcounts: %d\n", op->ob_refcnt); + fprintf(stderr, "address : %p\n", op); + } } #ifdef WITH_CYCLE_GC -- 2.50.0