From 1c1df0d9370fa5a14644850f09a7f9377bfc83be Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Mon, 13 Nov 2017 11:05:05 +0800 Subject: Fixed bug #75511 (fread not free unused buffer) --- ext/standard/file.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'ext/standard/file.c') diff --git a/ext/standard/file.c b/ext/standard/file.c index 52aa07b0b6..da10f58b65 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -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); + } } /* }}} */ -- cgit v1.2.1