@@ -215,17 +215,16 @@ static PHP_METHOD(Javascript, jsonSerialize)
215
215
php_phongo_bson_state state ;
216
216
217
217
PHONGO_BSON_INIT_STATE (state );
218
- if (php_phongo_bson_to_zval_ex (bson_get_data (intern -> scope ), intern -> scope -> len , & state )) {
218
+ if (!php_phongo_bson_to_zval_ex (bson_get_data (intern -> scope ), intern -> scope -> len , & state )) {
219
+ zval_ptr_dtor (& state .zchild );
220
+ return ;
221
+ }
222
+
219
223
#if PHP_VERSION_ID >= 70000
220
- Z_ADDREF (state .zchild );
221
- ADD_ASSOC_ZVAL_EX (return_value , "$scope" , & state .zchild );
224
+ ADD_ASSOC_ZVAL_EX (return_value , "$scope" , & state .zchild );
222
225
#else
223
- Z_ADDREF_P (state .zchild );
224
- ADD_ASSOC_ZVAL_EX (return_value , "$scope" , state .zchild );
226
+ ADD_ASSOC_ZVAL_EX (return_value , "$scope" , state .zchild );
225
227
#endif
226
- }
227
-
228
- zval_ptr_dtor (& state .zchild );
229
228
}
230
229
} /* }}} */
231
230
@@ -250,22 +249,21 @@ static PHP_METHOD(Javascript, serialize)
250
249
#if PHP_VERSION_ID >= 70000
251
250
if (intern -> scope && intern -> scope -> len ) {
252
251
if (!php_phongo_bson_to_zval_ex (bson_get_data (intern -> scope ), intern -> scope -> len , & state )) {
252
+ zval_ptr_dtor (& state .zchild );
253
253
return ;
254
254
}
255
- Z_ADDREF (state .zchild );
256
255
} else {
257
256
ZVAL_NULL (& state .zchild );
258
257
}
259
258
#else
260
259
if (intern -> scope && intern -> scope -> len ) {
261
260
if (!php_phongo_bson_to_zval_ex (bson_get_data (intern -> scope ), intern -> scope -> len , & state )) {
261
+ zval_ptr_dtor (& state .zchild );
262
262
return ;
263
263
}
264
- Z_ADDREF_P (state .zchild );
265
264
} else {
266
265
MAKE_STD_ZVAL (state .zchild );
267
266
ZVAL_NULL (state .zchild );
268
- Z_ADDREF_P (state .zchild );
269
267
}
270
268
#endif
271
269
@@ -289,7 +287,6 @@ static PHP_METHOD(Javascript, serialize)
289
287
290
288
smart_str_free (& buf );
291
289
zval_ptr_dtor (& retval );
292
- zval_ptr_dtor (& state .zchild );
293
290
} /* }}} */
294
291
295
292
/* {{{ proto void MongoDB\BSON\Javascript::unserialize(string $serialized)
@@ -490,17 +487,12 @@ HashTable* php_phongo_javascript_get_properties_hash(zval* object, bool is_debug
490
487
php_phongo_bson_state state ;
491
488
492
489
PHONGO_BSON_INIT_STATE (state );
493
- if (php_phongo_bson_to_zval_ex (bson_get_data (intern -> scope ), intern -> scope -> len , & state )) {
494
- Z_ADDREF (state .zchild );
495
- zend_hash_str_update (props , "scope" , sizeof ("scope" ) - 1 , & state .zchild );
496
- } else {
497
- zval scope ;
498
-
499
- ZVAL_NULL (& scope );
500
- zend_hash_str_update (props , "scope" , sizeof ("scope" ) - 1 , & scope );
490
+ if (!php_phongo_bson_to_zval_ex (bson_get_data (intern -> scope ), intern -> scope -> len , & state )) {
491
+ zval_ptr_dtor (& state .zchild );
492
+ goto failure ;
501
493
}
502
494
503
- zval_ptr_dtor ( & state .zchild );
495
+ zend_hash_str_update ( props , "scope" , sizeof ( "scope" ) - 1 , & state .zchild );
504
496
} else {
505
497
zval scope ;
506
498
@@ -520,18 +512,12 @@ HashTable* php_phongo_javascript_get_properties_hash(zval* object, bool is_debug
520
512
php_phongo_bson_state state ;
521
513
522
514
PHONGO_BSON_INIT_STATE (state );
523
- if (php_phongo_bson_to_zval_ex (bson_get_data (intern -> scope ), intern -> scope -> len , & state )) {
524
- Z_ADDREF_P (state .zchild );
525
- zend_hash_update (props , "scope" , sizeof ("scope" ), & state .zchild , sizeof (state .zchild ), NULL );
526
- } else {
527
- zval * scope ;
528
-
529
- MAKE_STD_ZVAL (scope );
530
- ZVAL_NULL (scope );
531
- zend_hash_update (props , "scope" , sizeof ("scope" ), & scope , sizeof (scope ), NULL );
515
+ if (!php_phongo_bson_to_zval_ex (bson_get_data (intern -> scope ), intern -> scope -> len , & state )) {
516
+ zval_ptr_dtor (& state .zchild );
517
+ goto failure ;
532
518
}
533
519
534
- zval_ptr_dtor ( & state .zchild );
520
+ zend_hash_update ( props , "scope" , sizeof ( "scope" ), & state .zchild , sizeof ( state . zchild ), NULL );
535
521
} else {
536
522
zval * scope ;
537
523
@@ -543,6 +529,10 @@ HashTable* php_phongo_javascript_get_properties_hash(zval* object, bool is_debug
543
529
#endif
544
530
545
531
return props ;
532
+
533
+ failure :
534
+ PHONGO_GET_PROPERTY_HASH_FREE_PROPS (is_debug , props );
535
+ return NULL ;
546
536
} /* }}} */
547
537
548
538
static HashTable * php_phongo_javascript_get_debug_info (zval * object , int * is_temp TSRMLS_DC ) /* {{{ */
0 commit comments