Merge branch 'PHP-8.2' into PHP-8.3

This commit is contained in:
Jakub Zelenka 2023-12-15 14:13:41 +00:00
commit 1b8be9acf0
No known key found for this signature in database
GPG key ID: 1C0779DC5C0A9DE4
4 changed files with 35 additions and 0 deletions

4
NEWS
View file

@ -14,6 +14,10 @@ PHP NEWS
. Fixed bug GH-12870 (Creating an xmlns attribute results in a DOMException). . Fixed bug GH-12870 (Creating an xmlns attribute results in a DOMException).
(nielsdos) (nielsdos)
- FFI:
. Fixed bug GH-9698 (stream_wrapper_register crashes with FFI\CData).
(Jakub Zelenka)
- Hash: - Hash:
. Fixed bug GH-12936 (hash() function hangs endlessly if using sha512 on . Fixed bug GH-12936 (hash() function hangs endlessly if using sha512 on
strings >= 4GiB). (nielsdos) strings >= 4GiB). (nielsdos)

View file

@ -1302,6 +1302,10 @@ static zval *zend_ffi_cdata_write_field(zend_object *obj, zend_string *field_nam
if (cache_slot && *cache_slot == type) { if (cache_slot && *cache_slot == type) {
field = *(cache_slot + 1); field = *(cache_slot + 1);
} else { } else {
if (UNEXPECTED(type == NULL)) {
zend_throw_error(zend_ffi_exception_ce, "Attempt to assign field '%s' to uninitialized FFI\\CData object", ZSTR_VAL(field_name));
return value;
}
if (type->kind == ZEND_FFI_TYPE_POINTER) { if (type->kind == ZEND_FFI_TYPE_POINTER) {
type = ZEND_FFI_TYPE(type->pointer.type); type = ZEND_FFI_TYPE(type->pointer.type);
} }

21
ext/ffi/tests/gh9698.phpt Normal file
View file

@ -0,0 +1,21 @@
--TEST--
GH-9698 (stream_wrapper_register crashes with FFI\CData provided as class)
--EXTENSIONS--
ffi
--SKIPIF--
<?php
?>
--FILE--
<?php
try {
stream_wrapper_register('badffi', 'FFI\CData');
file_get_contents('badffi://x');
} catch (Throwable $exception) {
echo $exception->getMessage();
}
?>
DONE
--EXPECT--
Attempt to assign field 'context' to uninitialized FFI\CData object
DONE

View file

@ -278,6 +278,12 @@ static void user_stream_create_object(struct php_user_stream_wrapper *uwrap, php
add_property_null(object, "context"); add_property_null(object, "context");
} }
if (EG(exception) != NULL) {
zval_ptr_dtor(object);
ZVAL_UNDEF(object);
return;
}
if (uwrap->ce->constructor) { if (uwrap->ce->constructor) {
zend_call_known_instance_method_with_0_params( zend_call_known_instance_method_with_0_params(
uwrap->ce->constructor, Z_OBJ_P(object), NULL); uwrap->ce->constructor, Z_OBJ_P(object), NULL);