diff options
author | Eclips4 <80244920+Eclips4@users.noreply.github.com> | 2023-02-16 17:46:43 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-16 17:46:43 (GMT) |
commit | 68bd8c5e2efab64ff9d38a214775164182179431 (patch) | |
tree | 09bd0d5138c62ef43b51a8e8ee16ca6ca1ef3c93 | |
parent | 924a3bfa28578802eb9ca77a66fb5d4762a62f14 (diff) | |
download | cpython-68bd8c5e2efab64ff9d38a214775164182179431.zip cpython-68bd8c5e2efab64ff9d38a214775164182179431.tar.gz cpython-68bd8c5e2efab64ff9d38a214775164182179431.tar.bz2 |
gh-101952: Fix possible segfault in `BUILD_SET` opcode (#101958)
-rw-r--r-- | Misc/NEWS.d/next/Core and Builtins/2023-02-16-16-57-23.gh-issue-101952.Zo1dlq.rst | 1 | ||||
-rw-r--r-- | Python/bytecodes.c | 2 | ||||
-rw-r--r-- | Python/generated_cases.c.h | 2 |
3 files changed, 5 insertions, 0 deletions
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 index 0000000..3902c98 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2023-02-16-16-57-23.gh-issue-101952.Zo1dlq.rst @@ -0,0 +1 @@ +Fix possible segfault in ``BUILD_SET`` opcode, when new set created. diff --git a/Python/bytecodes.c b/Python/bytecodes.c index d5d5034..84747f1 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -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]; diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 8b8a716..730dfb7 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -1649,6 +1649,8 @@ 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]; |