Skip to content

Commit 618b480

Browse files
committed
- Fix #55301 (readline part) check if malloc succeded
1 parent bc165d3 commit 618b480

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)