Skip to content

Commit 923c45b

Browse files
committed
Fix #79650: php-win.exe 100% cpu lockup
As of PHP 7.3.0, `sapi_cli_single_write()` is supposed to return `< 0` on failure, but `fwrite()` returns a `size_t`, and signals error by setting the stream's error indicator. We have to cater to that.
1 parent 744f901 commit 923c45b

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 7.3.20
44

5+
- Core:
6+
. Fixed bug #79650 (php-win.exe 100% cpu lockup). (cmb)
57

68
?? ??? ????, PHP 7.3.19
79

sapi/cli/php_cli.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@ PHP_CLI_API ssize_t sapi_cli_single_write(const char *str, size_t str_length) /*
279279
} while (ret <= 0 && errno == EAGAIN && sapi_cli_select(STDOUT_FILENO));
280280
#else
281281
ret = fwrite(str, 1, MIN(str_length, 16384), stdout);
282+
if (ret == 0 && ferror(stdout)) {
283+
return -1;
284+
}
282285
#endif
283286
return ret;
284287
}

0 commit comments

Comments
 (0)