]> granicus.if.org Git - php/commitdiff
- Fix #55301 (readline part) check if malloc succeded
authorPierre Joye <pajoye@php.net>
Thu, 28 Jul 2011 10:42:45 +0000 (10:42 +0000)
committerPierre Joye <pajoye@php.net>
Thu, 28 Jul 2011 10:42:45 +0000 (10:42 +0000)
ext/readline/readline.c

index cf80e0cd7b5a6ce67ae27b709f538af89d02ff5a..f57f3754128480ce04d115ba3fa2cff12c6471ea 100644 (file)
@@ -465,6 +465,9 @@ static char **_readline_completion_cb(const char *text, int start, int end)
                                matches = rl_completion_matches(text,_readline_command_generator);
                        } else {
                                matches = malloc(sizeof(char *) * 2);
+                               if (!matches) {
+                                       return NULL;
+                               }
                                matches[0] = strdup("");
                                matches[1] = '\0';
                        }
@@ -505,7 +508,10 @@ PHP_FUNCTION(readline_completion_function)
        zval_copy_ctor(_readline_completion);
 
        rl_attempted_completion_function = _readline_completion_cb;
-
+       if (rl_attempted_completion_function == NULL) {
+               efree(name);
+               RETURN_FALSE;
+       }
        RETURN_TRUE;
 }