]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-150372: Add missing null check on completer_word_break_characters in readli...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 31 May 2026 11:59:17 +0000 (13:59 +0200)
committerGitHub <noreply@github.com>
Sun, 31 May 2026 11:59:17 +0000 (14:59 +0300)
(cherry picked from commit 56bd9ea676d5ab4d5f6c68aefc3125ef5a216157)

Co-authored-by: Thomas Kowalski <thom.kowa@gmail.com>
Misc/NEWS.d/next/Library/2026-05-25-07-22-05.gh-issue-150372.9hLqhe.rst [new file with mode: 0644]
Modules/readline.c

diff --git a/Misc/NEWS.d/next/Library/2026-05-25-07-22-05.gh-issue-150372.9hLqhe.rst b/Misc/NEWS.d/next/Library/2026-05-25-07-22-05.gh-issue-150372.9hLqhe.rst
new file mode 100644 (file)
index 0000000..7b83bd8
--- /dev/null
@@ -0,0 +1,2 @@
+:mod:`readline`: Fix a potential crash during tab completion caused by an
+out-of-memory error during module initialization.
index 8475846eefc905ccda72f0ead76d0173854e2292..7708f47d4d0327918f19203496f0ffd8bf763be4 100644 (file)
@@ -1382,6 +1382,10 @@ setup_readline(readlinestate *mod_state)
     completer_word_break_characters =
         strdup(" \t\n`~!@#$%^&*()-=+[{]}\\|;:'\",<>/?");
         /* All nonalphanums except '.' */
+
+    if (!completer_word_break_characters) {
+        goto error;
+    }
 #ifdef WITH_EDITLINE
     // libedit uses rl_basic_word_break_characters instead of
     // rl_completer_word_break_characters as complete delimiter
@@ -1425,6 +1429,10 @@ setup_readline(readlinestate *mod_state)
 
     RESTORE_LOCALE(saved_locale)
     return 0;
+
+error:
+    RESTORE_LOCALE(saved_locale)
+    return -1;
 }
 
 /* Wrapper around GNU readline that handles signals differently. */