Skip to content

Commit db51bf3

Browse files
committed
Call cast_object handler from get_properties_for
1 parent b0a2727 commit db51bf3

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

Zend/zend_object_handlers.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,6 +1975,16 @@ ZEND_API HashTable *zend_std_get_properties_for(zend_object *obj, zend_prop_purp
19751975
}
19761976
ZEND_FALLTHROUGH;
19771977
case ZEND_PROP_PURPOSE_ARRAY_CAST:
1978+
if (obj->handlers->cast_object != std_object_handlers.cast_object) {
1979+
zval result;
1980+
if (obj->handlers->cast_object(obj, &result, IS_ARRAY) == SUCCESS) {
1981+
return Z_ARRVAL(result);
1982+
}
1983+
if (EG(exception)) {
1984+
return NULL;
1985+
}
1986+
}
1987+
ZEND_FALLTHROUGH;
19781988
case ZEND_PROP_PURPOSE_SERIALIZE:
19791989
case ZEND_PROP_PURPOSE_VAR_EXPORT:
19801990
case ZEND_PROP_PURPOSE_JSON:

ext/com_dotnet/com_handlers.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,10 @@ static int com_objects_compare(zval *object1, zval *object2)
431431

432432
static zend_result com_object_cast(zend_object *readobj, zval *writeobj, int type)
433433
{
434+
if (type == IS_ARRAY) {
435+
return FAILURE;
436+
}
437+
434438
php_com_dotnet_object *obj;
435439
VARIANT v;
436440
VARTYPE vt = VT_EMPTY;

ext/simplexml/simplexml.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,6 +1819,7 @@ static zend_result cast_object(zval *object, int type, char *contents)
18191819
convert_scalar_to_number(object);
18201820
break;
18211821
default:
1822+
zval_ptr_dtor_nogc(object);
18221823
return FAILURE;
18231824
}
18241825
return SUCCESS;

0 commit comments

Comments
 (0)