]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] gh-109216: Fix possible memory leak in `BUILD_MAP` (#109323)
authorNikita Sobolev <mail@sobolevn.me>
Thu, 12 Oct 2023 12:52:03 +0000 (15:52 +0300)
committerGitHub <noreply@github.com>
Thu, 12 Oct 2023 12:52:03 +0000 (12:52 +0000)
* [3.11] gh-109216: Fix possible memory leak in `BUILD_MAP`

* Add NEWS

* Update Python/ceval.c

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
---------

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Misc/NEWS.d/next/Core and Builtins/2023-09-11-12-41-42.gh-issue-109216.60QOSb.rst [new file with mode: 0644]
Python/ceval.c

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 (file)
index 0000000..f36310f
--- /dev/null
@@ -0,0 +1,2 @@
+Fix possible memory leak in :opcode:`BUILD_MAP`.
+
index 172bc4743bda903734ae02384ec51629fb23bc8d..bb6bb35030d2128598794fed02a374a5615c92f9 100644 (file)
@@ -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();
         }