Skip to content

Commit

Permalink
[3.11] gh-109216: Fix possible memory leak in BUILD_MAP (#109323)
Browse files Browse the repository at this point in the history
* [3.11] gh-109216: Fix possible memory leak in `BUILD_MAP`

* Add NEWS

* Update Python/ceval.c

Co-authored-by: Kumar Aditya <[email protected]>

---------

Co-authored-by: Kumar Aditya <[email protected]>
  • Loading branch information
sobolevn and kumaraditya303 authored Oct 12, 2023
1 parent c9214b9 commit e16922f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix possible memory leak in :opcode:`BUILD_MAP`.

5 changes: 3 additions & 2 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -3318,13 +3318,14 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
&PEEK(2*oparg), 2,
&PEEK(2*oparg - 1), 2,
oparg);
if (map == NULL)
goto error;

while (oparg--) {
Py_DECREF(POP());
Py_DECREF(POP());
}
if (map == NULL) {
goto error;
}
PUSH(map);
DISPATCH();
}
Expand Down

0 comments on commit e16922f

Please sign in to comment.