Skip to content

Commit bfd2a85

Browse files
author
Sascha Schumann
committed
Fix EOF cases
Noticed by: Ilia
1 parent 1918011 commit bfd2a85

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

main/streams.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,7 @@ static char *php_stream_locate_eol(php_stream *stream TSRMLS_DC)
656656
PHPAPI char *_php_stream_gets(php_stream *stream, char *buf, size_t maxlen TSRMLS_DC)
657657
{
658658
size_t avail = 0;
659+
int did_copy = 0;
659660

660661
if (maxlen == 0)
661662
return NULL;
@@ -704,6 +705,7 @@ PHPAPI char *_php_stream_gets(php_stream *stream, char *buf, size_t maxlen TSRML
704705
buf += cpysz;
705706
maxlen -= cpysz;
706707

708+
did_copy = 1;
707709
if (done) {
708710
break;
709711
}
@@ -721,6 +723,9 @@ PHPAPI char *_php_stream_gets(php_stream *stream, char *buf, size_t maxlen TSRML
721723
}
722724
}
723725

726+
if (!did_copy)
727+
return NULL;
728+
724729
buf[0] = '\0';
725730

726731
return buf;

0 commit comments

Comments
 (0)