]> 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 a5d0f7d2bac373e379ed71ba607a719651fa4b1f..e9cdacb275a4c0a13050147da9bd46d76dbc284d 100644 (file)
@@ -478,6 +478,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';
                        }
@@ -518,7 +521,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;
 }