Skip to content

Commit a4613e2

Browse files
committed
fix reference leak, after PyErr_Fetch we own the references
1 parent 2c882e0 commit a4613e2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Python/pythonrun.c

+9-3
Original file line numberDiff line numberDiff line change
@@ -1201,9 +1201,9 @@ print_exception_notes(struct exception_print_context *ctx, PyObject *notes)
12011201

12021202
static int
12031203
get_exception_notes(struct exception_print_context *ctx, PyObject *value, PyObject **notes) {
1204-
PyObject *type;
1205-
PyObject *errvalue;
1206-
PyObject *tback;
1204+
PyObject *type = NULL;
1205+
PyObject *errvalue = NULL;
1206+
PyObject *tback = NULL;
12071207
PyObject *note = NULL;
12081208

12091209
if (_PyObject_LookupAttr(value, &_Py_ID(__notes__), notes) < 0) {
@@ -1223,9 +1223,15 @@ get_exception_notes(struct exception_print_context *ctx, PyObject *value, PyObje
12231223
}
12241224
}
12251225

1226+
Py_XDECREF(type);
1227+
Py_XDECREF(errvalue);
1228+
Py_XDECREF(tback);
12261229
return 0;
12271230
error:
12281231
Py_XDECREF(note);
1232+
Py_XDECREF(type);
1233+
Py_XDECREF(errvalue);
1234+
Py_XDECREF(tback);
12291235
return -1;
12301236
}
12311237

0 commit comments

Comments
 (0)