commit 8a5ad8405024bc6cf3ae6ca0347a9e498e95016e Author: Todd Fiala Date: Fri Feb 14 13:57:27 2014 -0800 Guard against Python readline module NULL dereference. This fixes the following bug in lldb: http://llvm.org/bugs/show_bug.cgi?id=18841 diff --git a/Modules/readline.c b/Modules/readline.c index 0b043ae..777e55f 100644 --- a/Modules/readline.c +++ b/Modules/readline.c @@ -1099,6 +1099,7 @@ call_readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt) n = strlen(p); if (n > 0) { const char *line; + HIST_ENTRY *hist_entry; int length = _py_get_history_length(); if (length > 0) #ifdef __APPLE__ @@ -1107,7 +1108,13 @@ call_readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt) line = history_get(length + libedit_history_start - 1)->line; } else #endif /* __APPLE__ */ - line = history_get(length)->line; + { + hist_entry = history_get(length); + if (hist_entry) + line = history_get(length)->line; + else + line = ""; + }