summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSascha Schumann <sas@php.net>2002-10-04 19:48:59 +0000
committerSascha Schumann <sas@php.net>2002-10-04 19:48:59 +0000
commitbfd2a857b2919ed77810abbf200e96eaa1cbc857 (patch)
tree2ace2c1c01dae2c9456fa42c3d1866254fa55a48
parent1918011c01844c758bbf85ddf808bf9351167962 (diff)
downloadphp-git-bfd2a857b2919ed77810abbf200e96eaa1cbc857.tar.gz
Fix EOF cases
Noticed by: Ilia
-rwxr-xr-xmain/streams.c5
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;