1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.2' into PHP-8.3

This commit is contained in:
Jakub Zelenka
2023-12-15 14:13:41 +00:00
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).
(nielsdos)
- FFI:
. Fixed bug GH-9698 (stream_wrapper_register crashes with FFI\CData).
(Jakub Zelenka)
- Hash:
. Fixed bug GH-12936 (hash() function hangs endlessly if using sha512 on
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) {
field = *(cache_slot + 1);
} 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) {
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");
}
if (EG(exception) != NULL) {
zval_ptr_dtor(object);
ZVAL_UNDEF(object);
return;
}
if (uwrap->ce->constructor) {
zend_call_known_instance_method_with_0_params(
uwrap->ce->constructor, Z_OBJ_P(object), NULL);