From b4f35dabe87447a626fb3dc5254f23c8a0f0de4a Mon Sep 17 00:00:00 2001 From: An Long Date: Wed, 22 Jul 2026 00:39:20 +0900 Subject: [PATCH 1/4] Add missing NULL check on PyLong_FromLong in flex_complete in readline.c --- Modules/readline.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Modules/readline.c b/Modules/readline.c index 4c965e081c9d1a7..e160bd269c67039 100644 --- a/Modules/readline.c +++ b/Modules/readline.c @@ -1325,10 +1325,19 @@ flex_complete(const char *text, int start, int end) done: if (state) { - Py_XDECREF(state->begidx); - Py_XDECREF(state->endidx); - state->begidx = PyLong_FromLong((long) start); - state->endidx = PyLong_FromLong((long) end); + PyObject *begidx = PyLong_FromLong((long) start); + PyObject *endidx = PyLong_FromLong((long) end); + if (begidx == NULL || endidx == NULL) { + /* Keep the previous values so that get_begidx() and + get_endidx() never return NULL. */ + PyErr_Clear(); + Py_XDECREF(begidx); + Py_XDECREF(endidx); + } + else { + Py_XSETREF(state->begidx, begidx); + Py_XSETREF(state->endidx, endidx); + } } result = completion_matches((char *)text, *on_completion); PyGILState_Release(gilstate); From ec6d5d6b340d14936afbb7a82de87f8bd0724ca4 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Tue, 21 Jul 2026 16:13:49 +0000 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2026-07-21-16-13-43.gh-issue-154385.yQ6D2V.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2026-07-21-16-13-43.gh-issue-154385.yQ6D2V.rst diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-07-21-16-13-43.gh-issue-154385.yQ6D2V.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-07-21-16-13-43.gh-issue-154385.yQ6D2V.rst new file mode 100644 index 000000000000000..f6af34b8662632e --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-07-21-16-13-43.gh-issue-154385.yQ6D2V.rst @@ -0,0 +1,2 @@ +Fix a potential crash in :func:`readline.get_begidx` and +:func:`readline.get_endidx` caused by an out-of-memory error. From 9c75727e2f45b2836886b0845f8ef5700b86d980 Mon Sep 17 00:00:00 2001 From: An Long Date: Wed, 22 Jul 2026 01:35:27 +0900 Subject: [PATCH 3/4] Move NEWS entry to Library category and fix mixed line endings --- .../2026-07-21-16-13-43.gh-issue-154385.yQ6D2V.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename Misc/NEWS.d/next/{Core_and_Builtins => Library}/2026-07-21-16-13-43.gh-issue-154385.yQ6D2V.rst (99%) diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-07-21-16-13-43.gh-issue-154385.yQ6D2V.rst b/Misc/NEWS.d/next/Library/2026-07-21-16-13-43.gh-issue-154385.yQ6D2V.rst similarity index 99% rename from Misc/NEWS.d/next/Core_and_Builtins/2026-07-21-16-13-43.gh-issue-154385.yQ6D2V.rst rename to Misc/NEWS.d/next/Library/2026-07-21-16-13-43.gh-issue-154385.yQ6D2V.rst index f6af34b8662632e..1c86b0d38bc6f68 100644 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-07-21-16-13-43.gh-issue-154385.yQ6D2V.rst +++ b/Misc/NEWS.d/next/Library/2026-07-21-16-13-43.gh-issue-154385.yQ6D2V.rst @@ -1,2 +1,2 @@ -Fix a potential crash in :func:`readline.get_begidx` and +Fix a potential crash in :func:`readline.get_begidx` and :func:`readline.get_endidx` caused by an out-of-memory error. From 36b5643f5eaf4c02345c0b5e6a32ba696617b94f Mon Sep 17 00:00:00 2001 From: An Long Date: Wed, 22 Jul 2026 01:35:27 +0900 Subject: [PATCH 4/4] Fix news entry --- .../2026-07-21-16-13-43.gh-issue-154385.yQ6D2V.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename Misc/NEWS.d/next/{Core_and_Builtins => Library}/2026-07-21-16-13-43.gh-issue-154385.yQ6D2V.rst (99%) diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-07-21-16-13-43.gh-issue-154385.yQ6D2V.rst b/Misc/NEWS.d/next/Library/2026-07-21-16-13-43.gh-issue-154385.yQ6D2V.rst similarity index 99% rename from Misc/NEWS.d/next/Core_and_Builtins/2026-07-21-16-13-43.gh-issue-154385.yQ6D2V.rst rename to Misc/NEWS.d/next/Library/2026-07-21-16-13-43.gh-issue-154385.yQ6D2V.rst index f6af34b8662632e..1c86b0d38bc6f68 100644 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-07-21-16-13-43.gh-issue-154385.yQ6D2V.rst +++ b/Misc/NEWS.d/next/Library/2026-07-21-16-13-43.gh-issue-154385.yQ6D2V.rst @@ -1,2 +1,2 @@ -Fix a potential crash in :func:`readline.get_begidx` and +Fix a potential crash in :func:`readline.get_begidx` and :func:`readline.get_endidx` caused by an out-of-memory error.