]> granicus.if.org Git - php/commitdiff
Fixed bug #71094
authorNikita Popov <nikic@php.net>
Fri, 11 Dec 2015 15:32:10 +0000 (16:32 +0100)
committerNikita Popov <nikic@php.net>
Fri, 11 Dec 2015 15:33:07 +0000 (16:33 +0100)
I didn't see any non-dummy readline tests to work off, so this
change is tested manually only.

While at it also fix other zval_dtors and use ZVAL_COPY.

NEWS
ext/readline/readline.c

diff --git a/NEWS b/NEWS
index 89c5fa87ab2a5dc7b17d80cfbbc7ea1a34315118..6f2b4b270183859fb33c682e34ead8790aa1d5d7 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,10 @@ PHP                                                                        NEWS
   . Fixed bug #71066 (mb_send_mail: Program terminated with signal SIGSEGV,
     Segmentation fault). (Laruence)
 
+- Readline:
+  . Fixed bug #71094 (readline_completion_function corrupts static array on
+    second TAB). (Nikita)
+
 - SPL:
   . Fixed bug #71077 (ReflectionMethod for ArrayObject constructor returns
     wrong number of parameters). (Laruence)
index 47e59d8363922b2fd99cfbe0711fa025dd631538..5aca0518dbe1390936c3b22b50888ced39e204bd 100644 (file)
@@ -188,7 +188,7 @@ PHP_MSHUTDOWN_FUNCTION(readline)
 
 PHP_RSHUTDOWN_FUNCTION(readline)
 {
-       zval_dtor(&_readline_completion);
+       zval_ptr_dtor(&_readline_completion);
        ZVAL_UNDEF(&_readline_completion);
 #if HAVE_RL_CALLBACK_READ_CHAR
        if (Z_TYPE(_prepped_callback) != IS_UNDEF) {
@@ -505,7 +505,7 @@ static char **_readline_completion_cb(const char *text, int start, int end)
        for (i = 0; i < 3; i++) {
                zval_ptr_dtor(&params[i]);
        }
-       zval_dtor(&_readline_array);
+       zval_ptr_dtor(&_readline_array);
 
        return matches;
 }
@@ -526,8 +526,8 @@ PHP_FUNCTION(readline_completion_function)
        }
        zend_string_release(name);
 
-       zval_dtor(&_readline_completion);
-       ZVAL_DUP(&_readline_completion, arg);
+       zval_ptr_dtor(&_readline_completion);
+       ZVAL_COPY(&_readline_completion, arg);
 
        rl_attempted_completion_function = _readline_completion_cb;
        if (rl_attempted_completion_function == NULL) {
@@ -552,7 +552,7 @@ static void php_rl_callback_handler(char *the_line)
        call_user_function(CG(function_table), NULL, &_prepped_callback, &dummy, 1, params);
 
        zval_ptr_dtor(&params[0]);
-       zval_dtor(&dummy);
+       zval_ptr_dtor(&dummy);
 }
 
 /* {{{ proto void readline_callback_handler_install(string prompt, mixed callback)
@@ -577,10 +577,10 @@ PHP_FUNCTION(readline_callback_handler_install)
 
        if (Z_TYPE(_prepped_callback) != IS_UNDEF) {
                rl_callback_handler_remove();
-               zval_dtor(&_prepped_callback);
+               zval_ptr_dtor(&_prepped_callback);
        }
 
-       ZVAL_DUP(&_prepped_callback, callback);
+       ZVAL_COPY(&_prepped_callback, callback);
 
        rl_callback_handler_install(prompt, php_rl_callback_handler);
 
@@ -604,7 +604,7 @@ PHP_FUNCTION(readline_callback_handler_remove)
 {
        if (Z_TYPE(_prepped_callback) != IS_UNDEF) {
                rl_callback_handler_remove();
-               zval_dtor(&_prepped_callback);
+               zval_ptr_dtor(&_prepped_callback);
                ZVAL_UNDEF(&_prepped_callback);
                RETURN_TRUE;
        }