@@ -1534,8 +1534,6 @@ PHPAPI zend_string *_php_stream_copy_to_mem(php_stream *src, size_t maxlen, bool
1534
1534
ssize_t ret = 0 ;
1535
1535
char * ptr ;
1536
1536
size_t len = 0 , buflen ;
1537
- int step = CHUNK_SIZE ;
1538
- int min_room = CHUNK_SIZE / 4 ;
1539
1537
php_stream_statbuf ssbuf ;
1540
1538
zend_string * result ;
1541
1539
@@ -1578,31 +1576,32 @@ PHPAPI zend_string *_php_stream_copy_to_mem(php_stream *src, size_t maxlen, bool
1578
1576
* we can. Note that the stream may be filtered, in which case the stat
1579
1577
* result may be inaccurate, as the filter may inflate or deflate the
1580
1578
* number of bytes that we can read. In order to avoid an upsize followed
1581
- * by a downsize of the buffer, overestimate by the step size (which is
1579
+ * by a downsize of the buffer, overestimate by the CHUNK_SIZE size (which is
1582
1580
* 8K). */
1583
1581
if (php_stream_stat (src , & ssbuf ) == 0 && ssbuf .sb .st_size > 0 ) {
1584
- buflen = MAX (ssbuf .sb .st_size - src -> position , 0 ) + step ;
1582
+ buflen = MAX (ssbuf .sb .st_size - src -> position , 0 ) + CHUNK_SIZE ;
1585
1583
if (maxlen > 0 && buflen > maxlen ) {
1586
1584
buflen = maxlen ;
1587
1585
}
1588
1586
} else {
1589
- buflen = step ;
1587
+ buflen = CHUNK_SIZE ;
1590
1588
}
1591
1589
1592
1590
result = zend_string_alloc (buflen , persistent );
1593
1591
ptr = ZSTR_VAL (result );
1594
1592
1593
+ const int min_room = CHUNK_SIZE / 4 ;
1595
1594
// TODO: Propagate error?
1596
1595
while ((ret = php_stream_read (src , ptr , buflen - len )) > 0 ) {
1597
1596
len += ret ;
1598
1597
if (len + min_room >= buflen ) {
1599
1598
if (maxlen == len ) {
1600
1599
break ;
1601
1600
}
1602
- if (maxlen > 0 && buflen + step > maxlen ) {
1601
+ if (maxlen > 0 && buflen + CHUNK_SIZE > maxlen ) {
1603
1602
buflen = maxlen ;
1604
1603
} else {
1605
- buflen += step ;
1604
+ buflen += CHUNK_SIZE ;
1606
1605
}
1607
1606
result = zend_string_extend (result , buflen , persistent );
1608
1607
ptr = ZSTR_VAL (result ) + len ;
0 commit comments