diff options
Diffstat (limited to 'main/streams.c')
-rwxr-xr-x | main/streams.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/main/streams.c b/main/streams.c index ae6b83fa2c..8a23938aaf 100755 --- a/main/streams.c +++ b/main/streams.c @@ -656,6 +656,7 @@ static char *php_stream_locate_eol(php_stream *stream TSRMLS_DC) PHPAPI char *_php_stream_gets(php_stream *stream, char *buf, size_t maxlen TSRMLS_DC) { size_t avail = 0; + int did_copy = 0; if (maxlen == 0) return NULL; @@ -704,6 +705,7 @@ PHPAPI char *_php_stream_gets(php_stream *stream, char *buf, size_t maxlen TSRML buf += cpysz; maxlen -= cpysz; + did_copy = 1; if (done) { break; } @@ -721,6 +723,9 @@ PHPAPI char *_php_stream_gets(php_stream *stream, char *buf, size_t maxlen TSRML } } + if (!did_copy) + return NULL; + buf[0] = '\0'; return buf; |