Skip to content

Commit 0822b6c

Browse files
committed
Avoid checking dangling pointer against NULL.
1 parent 63892dc commit 0822b6c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Python/errors.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1493,9 +1493,10 @@ write_unraisable_exc_file(PyThreadState *tstate, PyObject *exc_type,
14931493
if (print_exception_fn != NULL && PyCallable_Check(print_exception_fn)) {
14941494
PyObject *args[2] = {exc_value, file};
14951495
PyObject *result = PyObject_Vectorcall(print_exception_fn, args, 2, NULL);
1496+
int ok = result != NULL;
14961497
Py_DECREF(print_exception_fn);
14971498
Py_XDECREF(result);
1498-
if (result != NULL) {
1499+
if (ok) {
14991500
// Nothing else to do
15001501
return 0;
15011502
}

0 commit comments

Comments
 (0)