https://github.com/python/cpython/commit/56bd9ea676d5ab4d5f6c68aefc3125ef5a216157
commit: 56bd9ea676d5ab4d5f6c68aefc3125ef5a216157
branch: main
author: Thomas Kowalski <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2026-05-30T19:26:05Z
summary:
gh-150372: Add missing null check on completer_word_break_characters in
readline.c (GH-150251)
files:
A Misc/NEWS.d/next/Library/2026-05-25-07-22-05.gh-issue-150372.9hLqhe.rst
M 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
index 00000000000000..7b83bd8fe73f11
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2026-05-25-07-22-05.gh-issue-150372.9hLqhe.rst
@@ -0,0 +1,2 @@
+:mod:`readline`: Fix a potential crash during tab completion caused by an
+out-of-memory error during module initialization.
diff --git a/Modules/readline.c b/Modules/readline.c
index 2cc3d40baa3aba..c580d2022fccf3 100644
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -1406,6 +1406,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
@@ -1449,6 +1453,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. */
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]