From 6a430997c1fc1345df1d83ffc44f406ff3d73a4f Mon Sep 17 00:00:00 2001 From: Eclips4 Date: Fri, 17 Feb 2023 01:23:20 +0200 Subject: [PATCH 1/4] gh-101967: Fix possible segfault in positional_only_passed_as_keyword --- .../2023-02-16-23-19-01.gh-issue-101967.Kqr1dz.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2023-02-16-23-19-01.gh-issue-101967.Kqr1dz.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-02-16-23-19-01.gh-issue-101967.Kqr1dz.rst b/Misc/NEWS.d/next/Core and Builtins/2023-02-16-23-19-01.gh-issue-101967.Kqr1dz.rst new file mode 100644 index 00000000000000..6e681f910f5359 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2023-02-16-23-19-01.gh-issue-101967.Kqr1dz.rst @@ -0,0 +1 @@ +Fix possible segfault in ``positional_only_passed_as_keyword`` function, when new list created. From b054c19f0480ef89a43c9a99e2b4d7f91d17d80f Mon Sep 17 00:00:00 2001 From: Eclips4 Date: Fri, 17 Feb 2023 01:24:15 +0200 Subject: [PATCH 2/4] gh-101967: Fix possible segfault in positional_only_passed_as_keyword --- Python/ceval.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Python/ceval.c b/Python/ceval.c index 09fd2f29266c87..3f76009034335f 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1255,7 +1255,8 @@ positional_only_passed_as_keyword(PyThreadState *tstate, PyCodeObject *co, { int posonly_conflicts = 0; PyObject* posonly_names = PyList_New(0); - + if (posonly_names == NULL) + return 1; for(int k=0; k < co->co_posonlyargcount; k++){ PyObject* posonly_name = PyTuple_GET_ITEM(co->co_localsplusnames, k); From 5d2625073ac5427822a5e29dd5c5366e1c2367c1 Mon Sep 17 00:00:00 2001 From: Eclips4 <80244920+Eclips4@users.noreply.github.com> Date: Fri, 17 Feb 2023 16:00:08 +0300 Subject: [PATCH 3/4] Update Python/ceval.c Co-authored-by: Nikita Sobolev --- Python/ceval.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/ceval.c b/Python/ceval.c index 3f76009034335f..361c5be3fd86a2 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1256,7 +1256,7 @@ positional_only_passed_as_keyword(PyThreadState *tstate, PyCodeObject *co, int posonly_conflicts = 0; PyObject* posonly_names = PyList_New(0); if (posonly_names == NULL) - return 1; + goto fail; for(int k=0; k < co->co_posonlyargcount; k++){ PyObject* posonly_name = PyTuple_GET_ITEM(co->co_localsplusnames, k); From 31463b7e8c0e6ef7d7a92f28f58bb312bc9a5d08 Mon Sep 17 00:00:00 2001 From: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> Date: Sat, 18 Feb 2023 00:22:28 +0000 Subject: [PATCH 4/4] {} to match style of the rest of the function --- Python/ceval.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index 361c5be3fd86a2..308ef52259df3d 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1255,8 +1255,9 @@ positional_only_passed_as_keyword(PyThreadState *tstate, PyCodeObject *co, { int posonly_conflicts = 0; PyObject* posonly_names = PyList_New(0); - if (posonly_names == NULL) - goto fail; + if (posonly_names == NULL) { + goto fail; + } for(int k=0; k < co->co_posonlyargcount; k++){ PyObject* posonly_name = PyTuple_GET_ITEM(co->co_localsplusnames, k);