]> granicus.if.org Git - php/commitdiff
Proper fix for bug #31796 .
authorIlia Alshanetsky <iliaa@php.net>
Fri, 4 Feb 2005 00:21:50 +0000 (00:21 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Fri, 4 Feb 2005 00:21:50 +0000 (00:21 +0000)
ext/readline/readline.c

index a11646b29adabb281bb48bce771ee94929a51ae4..28d7ed709cbd5615125df77f6257ddada3128aaa 100644 (file)
@@ -377,7 +377,7 @@ static char *_readline_command_generator(char *text,int state)
                }
        }
 
-       return strdup("");
+       return NULL;
 }
 
 static zval *_readline_string_zval(const char *str)
@@ -420,7 +420,13 @@ static char **_readline_completion_cb(const char *text, int start, int end)
 
        if (call_user_function(CG(function_table), NULL, _readline_completion, &_readline_array, 3, params TSRMLS_CC) == SUCCESS) {
                if (Z_TYPE(_readline_array) == IS_ARRAY) {
-                       matches = completion_matches(text,_readline_command_generator);
+                       if (zend_hash_num_elements(Z_ARRVAL(_readline_array))) {
+                               matches = completion_matches(text,_readline_command_generator);
+                       } else {
+                               matches = malloc(sizeof(char *) * 2);
+                               matches[0] = strdup("");
+                               matches[1] = '\0';
+                       }
                }
        }