]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-101952: Fix possible segfault in `BUILD_SET` opcode (#101958)
authorEclips4 <80244920+Eclips4@users.noreply.github.com>
Thu, 16 Feb 2023 17:46:43 +0000 (20:46 +0300)
committerGitHub <noreply@github.com>
Thu, 16 Feb 2023 17:46:43 +0000 (09:46 -0800)
Misc/NEWS.d/next/Core and Builtins/2023-02-16-16-57-23.gh-issue-101952.Zo1dlq.rst [new file with mode: 0644]
Python/bytecodes.c
Python/generated_cases.c.h

diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-02-16-16-57-23.gh-issue-101952.Zo1dlq.rst b/Misc/NEWS.d/next/Core and Builtins/2023-02-16-16-57-23.gh-issue-101952.Zo1dlq.rst
new file mode 100644 (file)
index 0000000..3902c98
--- /dev/null
@@ -0,0 +1 @@
+Fix possible segfault in ``BUILD_SET`` opcode, when new set created.
index d5d5034cbfbf74bfe484c0015fb44174a0d778ce..84747f1758e06c859fddfb64cac15b98a0b97e2e 100644 (file)
@@ -1302,6 +1302,8 @@ dummy_func(
 
         inst(BUILD_SET, (values[oparg] -- set)) {
             set = PySet_New(NULL);
+            if (set == NULL)
+                goto error;
             int err = 0;
             for (int i = 0; i < oparg; i++) {
                 PyObject *item = values[i];
index 8b8a7161ad898ef4089ac1c94f7a75e48e4f26d2..730dfb7426acbf8e133a65dba1b1cac65f263c05 100644 (file)
             PyObject **values = &PEEK(oparg);
             PyObject *set;
             set = PySet_New(NULL);
+            if (set == NULL)
+                goto error;
             int err = 0;
             for (int i = 0; i < oparg; i++) {
                 PyObject *item = values[i];