Skip to content

Commit bc9f2fb

Browse files
committed
Fixed bug #69212
1 parent c814b32 commit bc9f2fb

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ PHP NEWS
88
. Fixed bug #67626 (User exceptions not properly handled in streams).
99
(Julian)
1010
. Fixed bug #68917 (parse_url fails on some partial urls). (Wei Dai)
11+
. Fixed bug #69212 (Leaking VIA_HANDLER func when exception thrown in
12+
__call/... arg passing). (Nikita)
1113

1214
- Filter:
1315
. Fixed bug #69202: (FILTER_FLAG_STRIP_BACKTICK ignored unless other

Zend/tests/bug69212.phpt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--TEST--
2+
Bug #69212: Leaking VIA_HANDLER func when exception thrown in __call/... arg passing
3+
--FILE--
4+
<?php
5+
6+
class Test {
7+
public static function __callStatic($method, $args) {}
8+
public function __call($method, $args) {}
9+
}
10+
11+
function do_throw() { throw new Exception; }
12+
13+
try {
14+
Test::foo(do_throw());
15+
} catch (Exception $e) {
16+
echo "Caught!\n";
17+
}
18+
try {
19+
(new Test)->bar(do_throw());
20+
} catch (Exception $e) {
21+
echo "Caught!\n";
22+
}
23+
24+
?>
25+
--EXPECT--
26+
Caught!
27+
Caught!

Zend/zend_vm_def.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5042,6 +5042,10 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY)
50425042
}
50435043
zval_ptr_dtor(&call->object);
50445044
}
5045+
if (call->fbc->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) {
5046+
efree((char *) call->fbc->common.function_name);
5047+
efree(call->fbc);
5048+
}
50455049
call--;
50465050
} while (call >= EX(call_slots));
50475051
EX(call) = NULL;

Zend/zend_vm_execute.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,10 @@ static int ZEND_FASTCALL ZEND_HANDLE_EXCEPTION_SPEC_HANDLER(ZEND_OPCODE_HANDLER
10221022
}
10231023
zval_ptr_dtor(&call->object);
10241024
}
1025+
if (call->fbc->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) {
1026+
efree((char *) call->fbc->common.function_name);
1027+
efree(call->fbc);
1028+
}
10251029
call--;
10261030
} while (call >= EX(call_slots));
10271031
EX(call) = NULL;

0 commit comments

Comments
 (0)