]> granicus.if.org Git - php/commitdiff
Fixed bug #75511 (fread not free unused buffer)
authorXinchen Hui <laruence@gmail.com>
Mon, 13 Nov 2017 03:05:05 +0000 (11:05 +0800)
committerXinchen Hui <laruence@gmail.com>
Mon, 13 Nov 2017 03:13:27 +0000 (11:13 +0800)
NEWS
ext/standard/file.c

diff --git a/NEWS b/NEWS
index 05bbd5c06d3f63bd4b1680f08cb2d1ce17a31988..8b592a410e9500916c28c770a2602848fcde2725 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,9 @@ PHP                                                                        NEWS
   . Fixed bug #75384 (PHP seems incompatible with OneDrive files on demand).
     (Anatol)
 
+- Standard:
+  . Fixed bug #75511 (fread not free unused buffer). (Laruence)
+
 23 Nov 2017, PHP 7.1.12
 
 - Core:
index 52aa07b0b681c968d38240295e1f7d2203ad20ea..da10f58b6578a151df87356c2c4dd58982ab29ea 100644 (file)
@@ -1771,6 +1771,10 @@ PHPAPI PHP_FUNCTION(fread)
 
        /* needed because recv/read/gzread doesnt put a null at the end*/
        Z_STRVAL_P(return_value)[Z_STRLEN_P(return_value)] = 0;
+
+       if (len > Z_STRLEN_P(return_value) * 2) {
+               Z_STR_P(return_value) = zend_string_truncate(Z_STR_P(return_value), Z_STRLEN_P(return_value), 0);
+       }
 }
 /* }}} */