mirror of
https://github.com/php/php-src.git
synced 2024-09-22 10:27:25 +00:00
Fix EOF cases
Noticed by: Ilia
This commit is contained in:
parent
1918011c01
commit
bfd2a857b2
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user