From f1e045c9fa3fd0ea9fc4492ec746957c21b58ab2 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Tue, 12 Sep 2023 15:46:57 +0300 Subject: [PATCH 1/3] [3.11] gh-109216: Fix possible memory leak in `BUILD_MAP` --- Python/ceval.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index df11de084d2d72..d911523e916aa2 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3310,13 +3310,13 @@ _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(); } From 5cdb81393d0430b06a8df8501a7ee8f671827c1e Mon Sep 17 00:00:00 2001 From: sobolevn Date: Tue, 12 Sep 2023 15:49:02 +0300 Subject: [PATCH 2/3] Add NEWS --- .../2023-09-11-12-41-42.gh-issue-109216.60QOSb.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2023-09-11-12-41-42.gh-issue-109216.60QOSb.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-09-11-12-41-42.gh-issue-109216.60QOSb.rst b/Misc/NEWS.d/next/Core and Builtins/2023-09-11-12-41-42.gh-issue-109216.60QOSb.rst new file mode 100644 index 00000000000000..f36310fc5f8064 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2023-09-11-12-41-42.gh-issue-109216.60QOSb.rst @@ -0,0 +1,2 @@ +Fix possible memory leak in :opcode:`BUILD_MAP`. + From f00481cbb13f6b6537d6d2d455f87aeddf5ec83e Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Tue, 12 Sep 2023 15:57:46 +0300 Subject: [PATCH 3/3] Update Python/ceval.c Co-authored-by: Kumar Aditya --- Python/ceval.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Python/ceval.c b/Python/ceval.c index d911523e916aa2..20adbd7a82c85b 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3315,8 +3315,9 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int Py_DECREF(POP()); Py_DECREF(POP()); } - if (map == NULL) + if (map == NULL) { goto error; + } PUSH(map); DISPATCH(); }