Skip to content

Commit a925498

Browse files
committed
fix refleak of exit when __enter__ raises
1 parent 0a5f78d commit a925498

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Diff for: Python/bytecodes.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -2331,7 +2331,10 @@ dummy_func(
23312331
DECREF_INPUTS();
23322332
res = _PyObject_CallNoArgs(enter);
23332333
Py_DECREF(enter);
2334-
ERROR_IF(res == NULL, error);
2334+
if (res == NULL) {
2335+
Py_DECREF(exit);
2336+
ERROR_IF(true, error);
2337+
}
23352338
}
23362339

23372340
inst(WITH_EXCEPT_START, (exit_func, lasti, unused, val -- exit_func, lasti, unused, val, res)) {

Diff for: Python/generated_cases.c.h

+4-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)