cvs: php4(PHP_4_3) /main streams.c

From: Date: Fri, 23 May 2003 11:10:34 +0000
Subject: cvs: php4(PHP_4_3) /main streams.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-21221@lists.php.net to get a copy of this message
wez Fri May 23 07:10:35 2003 EDT Modified files: (Branch: PHP_4_3) /php4/main streams.c Log: Fix Bug #23770: Odd output from file_get_contents(). php_stream_copy_to_mem couldn't handle the case when the read returned less than chunk_size/4 bytes (except when it was the last chunk read). Index: php4/main/streams.c diff -u php4/main/streams.c:1.125.2.64 php4/main/streams.c:1.125.2.65 --- php4/main/streams.c:1.125.2.64 Wed May 21 08:02:55 2003 +++ php4/main/streams.c Fri May 23 07:10:34 2003 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: streams.c,v 1.125.2.64 2003/05/21 12:02:55 wez Exp $ */ +/* $Id: streams.c,v 1.125.2.65 2003/05/23 11:10:34 wez Exp $ */ #define _GNU_SOURCE #include "php.h" @@ -545,10 +545,10 @@ static void php_stream_fill_read_buffer(php_stream *stream, size_t size TSRMLS_DC) { /* allocate/fill the buffer */ - + size_t justread = 0; + /* is there enough data in the buffer ? */ if (stream->writepos - stream->readpos < (off_t)size) { - size_t justread = 0; /* ignore eof here; the underlying state might have changed */ @@ -583,13 +583,12 @@ stream->writepos += justread; } } - } PHPAPI size_t _php_stream_read(php_stream *stream, char *buf, size_t size TSRMLS_DC) { size_t toread = 0, didread = 0; - + while (size > 0) { /* take from the read buffer first. @@ -1185,13 +1184,15 @@ } ptr = *buf = pemalloc_rel_orig(max_len, persistent); - + while((ret = php_stream_read(src, ptr, max_len - len))) { len += ret; if (len + min_room >= max_len) { *buf = perealloc_rel_orig(*buf, max_len + step, persistent); max_len += step; ptr = *buf + len; + } else { + ptr += ret; } } if (len) {

« previous php.cvs (#21221) next »