Skip to content

Commit 103dc3c

Browse files
committed
fix refleak
1 parent d7a4c4c commit 103dc3c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Python/import.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2324,6 +2324,7 @@ remove_importlib_frames(PyThreadState *tstate)
23242324
int always_trim = 0;
23252325
int in_importlib = 0;
23262326
PyObject **prev_link, **outer_link = NULL;
2327+
PyObject *base_tb = NULL;
23272328

23282329
/* Synopsis: if it's an ImportError, we trim all importlib chunks
23292330
from the traceback. We always trim chunks
@@ -2339,7 +2340,7 @@ remove_importlib_frames(PyThreadState *tstate)
23392340
}
23402341

23412342
assert(PyExceptionInstance_Check(exc));
2342-
PyObject *base_tb = PyException_GetTraceback(exc);
2343+
base_tb = PyException_GetTraceback(exc);
23432344
prev_link = &base_tb;
23442345
PyObject *tb = base_tb;
23452346
while (tb != NULL) {
@@ -2376,6 +2377,7 @@ remove_importlib_frames(PyThreadState *tstate)
23762377
}
23772378
PyException_SetTraceback(exc, base_tb);
23782379
done:
2380+
Py_XDECREF(base_tb);
23792381
_PyErr_SetRaisedException(tstate, exc);
23802382
}
23812383

0 commit comments

Comments
 (0)