From e16922f07010a620298d7fb8abfae5c578d5d337 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Thu, 12 Oct 2023 15:52:03 +0300 Subject: [PATCH] [3.11] gh-109216: Fix possible memory leak in `BUILD_MAP` (#109323) * [3.11] gh-109216: Fix possible memory leak in `BUILD_MAP` * Add NEWS * Update Python/ceval.c Co-authored-by: Kumar Aditya --------- Co-authored-by: Kumar Aditya --- .../2023-09-11-12-41-42.gh-issue-109216.60QOSb.rst | 2 ++ Python/ceval.c | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) 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 00000000000..f36310fc5f8 --- /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`. + diff --git a/Python/ceval.c b/Python/ceval.c index 172bc4743bd..bb6bb35030d 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3318,13 +3318,14 @@ handle_eval_breaker: &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(); }