Skip to content

Commit 3151676

Browse files
committed
Fix #79514: Memory leaks while including unexistent file
We have to destroy (un-opened) ZEND_HANDLE_FILENAMEs.
1 parent 3676418 commit 3151676

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ PHP NEWS
66
- Core:
77
. Fixed bug #78434 (Generator yields no items after valid() call). (Nikita)
88
. Fixed bug #79477 (casting object into array creates references). (Nikita)
9+
. Fixed bug #79514 (Memory leaks while including unexistent file). (cmb,
10+
Nikita)
911

1012
- DOM:
1113
. Fixed bug #78221 (DOMNode::normalize() doesn't remove empty text nodes).

Zend/tests/bug79514.phpt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
Bug #79514 (Memory leaks while including unexistent file)
3+
--FILE--
4+
<?php
5+
$mem1 = memory_get_usage(true);
6+
for ($i = 0; $i < 100000; $i++) {
7+
@include __DIR__ . '/bug79514.doesnotexist';
8+
}
9+
$mem2 = memory_get_usage(true);
10+
var_dump($mem2 - $mem1 < 100000);
11+
?>
12+
--EXPECT--
13+
bool(true)

Zend/zend_stream.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ ZEND_API int zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *
238238
return 0;
239239
}
240240
switch (fh1->type) {
241+
case ZEND_HANDLE_FILENAME:
242+
return strcmp(fh1->filename, fh2->filename) == 0;
241243
case ZEND_HANDLE_FP:
242244
return fh1->handle.fp == fh2->handle.fp;
243245
case ZEND_HANDLE_STREAM:

0 commit comments

Comments
 (0)