]> granicus.if.org Git - php/commitdiff
Fixed Bug #66412 readline_clear_history() with libedit causes segfault after #65714
authorRemi Collet <remi@php.net>
Mon, 20 Jan 2014 07:38:53 +0000 (08:38 +0100)
committerRemi Collet <remi@php.net>
Mon, 20 Jan 2014 07:38:53 +0000 (08:38 +0100)
Checking all libedit functions, this check is done in each functions (add_history,
read_history, write_history, ...) but is missing in clear_history.

Test coverage: readline_clear_history_001.phpt

NEWS
ext/readline/readline.c

diff --git a/NEWS b/NEWS
index ce2d100799fb2e7b54017b02197f0446c5d7c14e..f03180d859341fcfbeb181b98c99c585e1003144 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,10 @@ PHP                                                                        NEWS
   . Fixed bug #66298 (ext/opcache/Optimizer/zend_optimizer.c has dos-style 
     ^M as lineend). (Laruence)
 
+- Readline
+  . Fixed Bug #66412 (readline_clear_history() with libedit causes segfault after
+    #65714). (Remi)
+
 - Session
   . Fixed bug #66469 (Session module is sending multiple set-cookie headers when
     session.use_strict_mode=1) (Yasuo)
index ecd55333504ec40e7ee4773bf90441e8a046adbe..4bd91034629d2deb5b05da8914d344c8a3314e57 100644 (file)
@@ -354,6 +354,11 @@ PHP_FUNCTION(readline_clear_history)
                return;
        }
 
+#if HAVE_LIBEDIT
+       /* clear_history is the only function where rl_initialize
+          is not call to ensure correct allocation */
+       using_history();
+#endif
        clear_history();
 
        RETURN_TRUE;