Skip to content

Commit d3fd31b

Browse files
committed
- Fix #55301 (readline part) check if malloc succeded
1 parent 7ec6d3a commit d3fd31b

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
@@ -465,6 +465,9 @@ static char **_readline_completion_cb(const char *text, int start, int end)
465465
matches = rl_completion_matches(text,_readline_command_generator);
466466
} else {
467467
matches = malloc(sizeof(char *) * 2);
468+
if (!matches) {
469+
return NULL;
470+
}
468471
matches[0] = strdup("");
469472
matches[1] = '\0';
470473
}
@@ -505,7 +508,10 @@ PHP_FUNCTION(readline_completion_function)
505508
zval_copy_ctor(_readline_completion);
506509

507510
rl_attempted_completion_function = _readline_completion_cb;
508-
511+
if (rl_attempted_completion_function == NULL) {
512+
efree(name);
513+
RETURN_FALSE;
514+
}
509515
RETURN_TRUE;
510516
}
511517

0 commit comments

Comments
 (0)