Skip to content

Commit

Permalink
fix refleak of exit when __enter__ raises
Browse files Browse the repository at this point in the history
  • Loading branch information
iritkatriel committed Jan 31, 2023
1 parent 0a5f78d commit a925498
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2331,7 +2331,10 @@ dummy_func(
DECREF_INPUTS();
res = _PyObject_CallNoArgs(enter);
Py_DECREF(enter);
ERROR_IF(res == NULL, error);
if (res == NULL) {
Py_DECREF(exit);
ERROR_IF(true, error);
}
}

inst(WITH_EXCEPT_START, (exit_func, lasti, unused, val -- exit_func, lasti, unused, val, res)) {
Expand Down
5 changes: 4 additions & 1 deletion Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a925498

Please sign in to comment.