@@ -764,15 +764,16 @@ static inline bool php_var_serialize_class_name(smart_str *buf, zval *struc) /*
764
764
}
765
765
/* }}} */
766
766
767
- static zend_result php_var_serialize_call_sleep (zend_object * obj , zend_function * fn , zval * retval ) /* {{{ */
767
+ static HashTable * php_var_serialize_call_sleep (zend_object * obj , zend_function * fn ) /* {{{ */
768
768
{
769
769
zend_result res ;
770
770
zend_fcall_info fci ;
771
771
zend_fcall_info_cache fci_cache ;
772
+ zval retval ;
772
773
773
774
fci .size = sizeof (fci );
774
775
fci .object = obj ;
775
- fci .retval = retval ;
776
+ fci .retval = & retval ;
776
777
fci .param_count = 0 ;
777
778
fci .params = NULL ;
778
779
fci .named_params = NULL ;
@@ -786,18 +787,18 @@ static zend_result php_var_serialize_call_sleep(zend_object *obj, zend_function
786
787
res = zend_call_function (& fci , & fci_cache );
787
788
BG (serialize_lock )-- ;
788
789
789
- if (res == FAILURE || Z_ISUNDEF_P (retval )) {
790
- zval_ptr_dtor (retval );
791
- return FAILURE ;
790
+ if (res == FAILURE || Z_ISUNDEF (retval )) {
791
+ zval_ptr_dtor (& retval );
792
+ return NULL ;
792
793
}
793
794
794
- if (! HASH_OF (retval )) {
795
- zval_ptr_dtor (retval );
795
+ if (Z_TYPE (retval ) != IS_ARRAY ) {
796
+ zval_ptr_dtor (& retval );
796
797
php_error_docref (NULL , E_WARNING , "%s::__sleep() should return an array only containing the names of instance-variables to serialize" , ZSTR_VAL (obj -> ce -> name ));
797
- return FAILURE ;
798
+ return NULL ;
798
799
}
799
800
800
- return SUCCESS ;
801
+ return Z_ARRVAL ( retval ) ;
801
802
}
802
803
/* }}} */
803
804
@@ -864,7 +865,7 @@ static int php_var_serialize_get_sleep_props(
864
865
zend_hash_init (ht , zend_hash_num_elements (sleep_retval ), NULL , ZVAL_PTR_DTOR , 0 );
865
866
/* TODO: Rewrite this by fetching the property info instead of trying out different
866
867
* name manglings? */
867
- ZEND_HASH_FOREACH_VAL (sleep_retval , name_val ) {
868
+ ZEND_HASH_FOREACH_VAL_IND (sleep_retval , name_val ) {
868
869
zend_string * name , * tmp_name , * priv_name , * prot_name ;
869
870
870
871
ZVAL_DEREF (name_val );
@@ -977,10 +978,11 @@ static void php_var_serialize_nested_data(smart_str *buf, zval *struc, HashTable
977
978
}
978
979
/* }}} */
979
980
980
- static void php_var_serialize_class (smart_str * buf , zval * struc , zval * retval_ptr , php_serialize_data_t var_hash ) /* {{{ */
981
+ static void php_var_serialize_class (smart_str * buf , zval * struc , HashTable * ht , php_serialize_data_t var_hash ) /* {{{ */
981
982
{
982
983
HashTable props ;
983
- if (php_var_serialize_get_sleep_props (& props , struc , HASH_OF (retval_ptr )) == SUCCESS ) {
984
+
985
+ if (php_var_serialize_get_sleep_props (& props , struc , ht ) == SUCCESS ) {
984
986
php_var_serialize_class_name (buf , struc );
985
987
php_var_serialize_nested_data (
986
988
buf , struc , & props , zend_hash_num_elements (& props ), /* incomplete_class */ 0 , var_hash );
@@ -1158,10 +1160,11 @@ static void php_var_serialize_intern(smart_str *buf, zval *struc, php_serialize_
1158
1160
zval * zv = zend_hash_find_ex (& ce -> function_table , ZSTR_KNOWN (ZEND_STR_SLEEP ), 1 );
1159
1161
1160
1162
if (zv ) {
1161
- zval retval , tmp ;
1163
+ HashTable * ht ;
1164
+ zval tmp ;
1162
1165
1163
1166
ZVAL_OBJ_COPY (& tmp , Z_OBJ_P (struc ));
1164
- if (php_var_serialize_call_sleep (Z_OBJ (tmp ), Z_FUNC_P (zv ), & retval ) == FAILURE ) {
1167
+ if (!( ht = php_var_serialize_call_sleep (Z_OBJ (tmp ), Z_FUNC_P (zv ))) ) {
1165
1168
if (!EG (exception )) {
1166
1169
/* we should still add element even if it's not OK,
1167
1170
* since we already wrote the length of the array before */
@@ -1171,8 +1174,8 @@ static void php_var_serialize_intern(smart_str *buf, zval *struc, php_serialize_
1171
1174
return ;
1172
1175
}
1173
1176
1174
- php_var_serialize_class (buf , & tmp , & retval , var_hash );
1175
- zval_ptr_dtor ( & retval );
1177
+ php_var_serialize_class (buf , & tmp , ht , var_hash );
1178
+ zend_array_release ( ht );
1176
1179
OBJ_RELEASE (Z_OBJ (tmp ));
1177
1180
return ;
1178
1181
}
0 commit comments