Skip to content

Commit 93eda6a

Browse files
author
pajoye
committed
- Fix #55301 (readline part) check if malloc succeded
git-svn-id: http://svn.php.net/repository/php/php-src/trunk@313831 c90b9560-bf6c-de11-be94-00142212c4b1
1 parent 7807ecd commit 93eda6a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ext/readline/readline.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,9 @@ static char **_readline_completion_cb(const char *text, int start, int end)
478478
matches = rl_completion_matches(text,_readline_command_generator);
479479
} else {
480480
matches = malloc(sizeof(char *) * 2);
481+
if (!matches) {
482+
return NULL;
483+
}
481484
matches[0] = strdup("");
482485
matches[1] = '\0';
483486
}
@@ -518,7 +521,10 @@ PHP_FUNCTION(readline_completion_function)
518521
zval_copy_ctor(_readline_completion);
519522

520523
rl_attempted_completion_function = _readline_completion_cb;
521-
524+
if (rl_attempted_completion_function == NULL) {
525+
efree(name);
526+
RETURN_FALSE;
527+
}
522528
RETURN_TRUE;
523529
}
524530

0 commit comments

Comments
 (0)