Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GH-17866: zend_mm_heap corrupted error after upgrading from 8.4.3 to 8.4.4 #17880

Open
wants to merge 2 commits into
base: PHP-8.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions Zend/tests/attributes/deprecated/functions/gh17866.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
--TEST--
GH-17866 (zend_mm_heap corrupted error after upgrading from 8.4.3 to 8.4.4)
--FILE--
<?php

class Foo {
#[Deprecated("xyzzy")]
public function __invoke() {
echo "In __invoke\n";
}
}

$foo = new Foo;
$closure = Closure::fromCallable($foo);
$test = $closure->__invoke(...);

$rc = new ReflectionMethod($test, '__invoke');
var_dump($rc->getAttributes());

$test();

?>
--EXPECTF--
array(1) {
[0]=>
object(ReflectionAttribute)#%d (1) {
["name"]=>
string(10) "Deprecated"
}
}

Deprecated: Method Foo::__invoke() is deprecated, xyzzy in %s on line %d
In __invoke
5 changes: 5 additions & 0 deletions Zend/zend_closures.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,11 @@ ZEND_API zend_function *zend_get_closure_invoke_method(zend_object *object) /* {
ZEND_ACC_RETURN_REFERENCE | ZEND_ACC_VARIADIC | ZEND_ACC_HAS_RETURN_TYPE;

invoke->common = closure->func.common;

if (invoke->common.attributes) {
GC_TRY_ADDREF(invoke->common.attributes);
}

/* We return ZEND_INTERNAL_FUNCTION, but arg_info representation is the
* same as for ZEND_USER_FUNCTION (uses zend_string* instead of char*).
* This is not a problem, because ZEND_ACC_HAS_TYPE_HINTS is never set,
Expand Down
Loading