Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eefb107

Browse files
committed
_PyObject_Dump(): If argument is NULL, print "NULL" instead of
crashing.
1 parent 2da0ea8 commit eefb107

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

Objects/object.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,13 @@ PyObject_Print(PyObject *op, FILE *fp, int flags)
231231
/* For debugging convenience. See Misc/gdbinit for some useful gdb hooks */
232232
void _PyObject_Dump(PyObject* op)
233233
{
234-
(void)PyObject_Print(op, stderr, 0);
235-
fprintf(stderr, "\nrefcounts: %d\n", op->ob_refcnt);
236-
fprintf(stderr, "address : %p\n", op);
234+
if (op == NULL)
235+
fprintf(stderr, "NULL\n");
236+
else {
237+
(void)PyObject_Print(op, stderr, 0);
238+
fprintf(stderr, "\nrefcounts: %d\n", op->ob_refcnt);
239+
fprintf(stderr, "address : %p\n", op);
240+
}
237241
}
238242

239243
#ifdef WITH_CYCLE_GC

0 commit comments

Comments
 (0)