Browse Source

Merge branch 'PHP-5.4'

* PHP-5.4:
  Add NEWS entry for bug #61961
  Fixed Bug #61961 (file_get_content leaks when access empty file with max length)
pull/78/merge
Nikita Popov 14 years ago
parent
commit
9e1b690e0c
  1. 14
      ext/standard/tests/file/bug61961.phpt
  2. 7
      main/streams/streams.c

14
ext/standard/tests/file/bug61961.phpt

@ -0,0 +1,14 @@
--TEST--
Bug #61961 (file_get_content leaks when access empty file with max length)
--FILE--
<?php
$tmp_empty_file = __FILE__ . ".tmp";
file_put_contents($tmp_empty_file, "");
var_dump(file_get_contents($tmp_empty_file, NULL, NULL, NULL, 10));
unlink($tmp_empty_file);
?>
==DONE==
--EXPECT--
string(0) ""
==DONE==

7
main/streams/streams.c

@ -1432,7 +1432,12 @@ PHPAPI size_t _php_stream_copy_to_mem(php_stream *src, char **buf, size_t maxlen
len += ret;
ptr += ret;
}
*ptr = '\0';
if (len) {
*ptr = '\0';
} else {
pefree(*buf, persistent);
*buf = NULL;
}
return len;
}

Loading…
Cancel
Save