We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f9d6735 commit 625f0a7Copy full SHA for 625f0a7
2 files changed
ext/zend_test/test.c
@@ -543,6 +543,9 @@ static ZEND_FUNCTION(zend_call_method_if_exists)
543
}
544
RETURN_NULL();
545
546
+ if (Z_TYPE_P(return_value) == IS_REFERENCE) {
547
+ zend_unwrap_reference(return_value);
548
+ }
549
550
551
static ZEND_FUNCTION(zend_test_call_with_consumed_args)
ext/zend_test/tests/gh22175.phpt
@@ -0,0 +1,18 @@
1
+--TEST--
2
+GH-22175: zend_call_method_if_exists() must unref return value
3
+--CREDITS--
4
+YuanchengJiang
5
+--EXTENSIONS--
6
+zend_test
7
+--FILE--
8
+<?php
9
+
10
+class Foo {
11
+ public function &test() {}
12
+}
13
14
+zend_call_method_if_exists(new Foo, 'test');
15
16
+?>
17
+--EXPECTF--
18
+Notice: Only variable references should be returned by reference in %s on line %d
0 commit comments