Fix #79514: Memory leaks while including unexistent file

We have to destroy (un-opened) ZEND_HANDLE_FILENAMEs.
This commit is contained in:
Christoph M. Becker 2020-04-24 14:51:44 +02:00
parent 3676418568
commit 3151676f52
3 changed files with 17 additions and 0 deletions

2
NEWS
View file

@ -6,6 +6,8 @@ PHP NEWS
- Core: - Core:
. Fixed bug #78434 (Generator yields no items after valid() call). (Nikita) . Fixed bug #78434 (Generator yields no items after valid() call). (Nikita)
. Fixed bug #79477 (casting object into array creates references). (Nikita) . Fixed bug #79477 (casting object into array creates references). (Nikita)
. Fixed bug #79514 (Memory leaks while including unexistent file). (cmb,
Nikita)
- DOM: - DOM:
. Fixed bug #78221 (DOMNode::normalize() doesn't remove empty text nodes). . Fixed bug #78221 (DOMNode::normalize() doesn't remove empty text nodes).

13
Zend/tests/bug79514.phpt Normal file
View file

@ -0,0 +1,13 @@
--TEST--
Bug #79514 (Memory leaks while including unexistent file)
--FILE--
<?php
$mem1 = memory_get_usage(true);
for ($i = 0; $i < 100000; $i++) {
@include __DIR__ . '/bug79514.doesnotexist';
}
$mem2 = memory_get_usage(true);
var_dump($mem2 - $mem1 < 100000);
?>
--EXPECT--
bool(true)

View file

@ -238,6 +238,8 @@ ZEND_API int zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *
return 0; return 0;
} }
switch (fh1->type) { switch (fh1->type) {
case ZEND_HANDLE_FILENAME:
return strcmp(fh1->filename, fh2->filename) == 0;
case ZEND_HANDLE_FP: case ZEND_HANDLE_FP:
return fh1->handle.fp == fh2->handle.fp; return fh1->handle.fp == fh2->handle.fp;
case ZEND_HANDLE_STREAM: case ZEND_HANDLE_STREAM: