Skip to content

Commit ff7fe63

Browse files
committed
Fix extension object handlers to satisfy new requirements
1 parent e81419d commit ff7fe63

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

Zend/zend_attributes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ ZEND_METHOD(SensitiveParameterValue, __debugInfo)
138138

139139
static HashTable *attributes_sensitive_parameter_value_get_properties_for(zend_object *zobj, zend_prop_purpose purpose)
140140
{
141-
return NULL;
141+
return (HashTable*)&zend_empty_array;
142142
}
143143

144144
ZEND_METHOD(Override, __construct)

Zend/zend_object_handlers.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,15 @@ typedef void (*zend_object_unset_property_t)(zend_object *object, zend_string *m
8282
/* Used to remove a dimension of the object */
8383
typedef void (*zend_object_unset_dimension_t)(zend_object *object, zval *offset);
8484

85-
/* Used to get hash of the properties of the object, as hash of zval's */
85+
/* Used to get hash of the properties of the object, as hash of zval's
86+
* Must only return NULL when an exception occurs, if no properties
87+
* return (HashTable*)&zend_empty_array;
88+
*/
8689
typedef HashTable *(*zend_object_get_properties_t)(zend_object *object);
8790

91+
/* Must only return NULL when an exception occurs, if no properties
92+
* return (HashTable*)&zend_empty_array;
93+
*/
8894
typedef HashTable *(*zend_object_get_debug_info_t)(zend_object *object, int *is_temp);
8995

9096
typedef enum _zend_prop_purpose {

ext/ffi/ffi.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2047,7 +2047,8 @@ static HashTable *zend_ffi_cdata_get_debug_info(zend_object *obj, int *is_temp)
20472047

20482048
switch (type->kind) {
20492049
case ZEND_FFI_TYPE_VOID:
2050-
return NULL;
2050+
*is_temp = false;
2051+
return (HashTable*)&zend_empty_array;
20512052
case ZEND_FFI_TYPE_BOOL:
20522053
case ZEND_FFI_TYPE_CHAR:
20532054
case ZEND_FFI_TYPE_ENUM:
@@ -2274,7 +2275,8 @@ static int zend_ffi_ctype_compare_objects(zval *o1, zval *o2) /* {{{ */
22742275

22752276
static HashTable *zend_ffi_ctype_get_debug_info(zend_object *obj, int *is_temp) /* {{{ */
22762277
{
2277-
return NULL;
2278+
*is_temp = false;
2279+
return (HashTable*)&zend_empty_array;
22782280
}
22792281
/* }}} */
22802282

ext/ffi/tests/035.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,4 @@ object(FFI\CData:uint16_t[2])#%d (2) {
2323
[1]=>
2424
int(0)
2525
}
26-
object(FFI\CData:uint16_t[2])#%d (0) {
27-
}
2826
FFI\Exception: Use after free()

ext/spl/spl_fixedarray.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ static HashTable* spl_fixedarray_object_get_properties_for(zend_object *obj, zen
238238

239239
const zend_long size = intern->array.size;
240240
if (size == 0 && (!source_properties || !zend_hash_num_elements(source_properties))) {
241-
return NULL;
241+
return (HashTable*)&zend_empty_array;
242242
}
243243
zval *const elements = intern->array.elements;
244244
HashTable *ht = zend_new_array(size);

0 commit comments

Comments
 (0)