Skip to content

Commit c0fe489

Browse files
authored
Merge pull request #41 from arnaud-lb/zend-pass-function
Fix crash on zend_pass_function encounters
2 parents a1cb6f8 + 57820cb commit c0fe489

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

memprof.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,9 @@ static void memprof_zend_execute_internal(zend_execute_data *execute_data_ptr, z
672672
{
673673
int ignore = 0;
674674

675-
if (execute_data_ptr->func->common.function_name) {
675+
if (execute_data_ptr->func == &zend_pass_function) {
676+
ignore = 1;
677+
} else if (execute_data_ptr->func->common.function_name) {
676678
zend_string * name = execute_data_ptr->func->common.function_name;
677679
if (ZSTR_LEN(name) == sizeof("call_user_func")-1
678680
&& 0 == memcmp(name, "call_user_func", sizeof("call_user_func")))

tests/zend_pass_function.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Enable with environment variable
3+
--ENV--
4+
MEMPROF_PROFILE=1
5+
--FILE--
6+
<?php
7+
var_dump(memprof_enabled());
8+
9+
class C {
10+
}
11+
12+
$a = new C(1, 2, 3);
13+
14+
var_dump($a);
15+
16+
memprof_dump_array();
17+
--EXPECT--
18+
bool(true)
19+
object(C)#1 (0) {
20+
}

util.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ size_t get_function_name(zend_execute_data * execute_data, char * buf, size_t bu
5656
return snprintf(buf, buf_size, "main");
5757
}
5858

59+
if (execute_data->func == &zend_pass_function) {
60+
return snprintf(buf, buf_size, "zend_pass_function");
61+
}
62+
5963
zname = func->common.function_name;
6064

6165
if (zname == NULL) {

0 commit comments

Comments
 (0)