Skip to content

Commit 0706148

Browse files
committed
Fix segfault in php -a without readline
1 parent 8b8c8fd commit 0706148

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

sapi/cli/php_cli.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -874,11 +874,13 @@ static int do_cli(int argc, char **argv) /* {{{ */
874874
#endif
875875

876876
if (interactive) {
877-
#if (defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT)) && !defined(COMPILE_DL_READLINE)
878-
printf("Interactive shell\n\n");
879-
#else
880-
printf("Interactive mode enabled\n\n");
881-
#endif
877+
if (cli_shell_callbacks.cli_shell_run) {
878+
printf("Interactive shell\n\n");
879+
} else {
880+
printf("Interactive mode enabled\n\n");
881+
/* Treat as non-interactive apart from the stdin input */
882+
interactive = false;
883+
}
882884
fflush(stdout);
883885
}
884886

@@ -963,7 +965,7 @@ static int do_cli(int argc, char **argv) /* {{{ */
963965
cli_register_file_handles(/* no_close */ PHP_DEBUG || num_repeats > 1);
964966
}
965967

966-
if (interactive && cli_shell_callbacks.cli_shell_run) {
968+
if (interactive) {
967969
EG(exit_status) = cli_shell_callbacks.cli_shell_run();
968970
} else {
969971
php_execute_script(&file_handle);

0 commit comments

Comments
 (0)