diff options
Diffstat (limited to 'ext/spl')
| -rw-r--r-- | ext/spl/spl_array.c | 20 | ||||
| -rw-r--r-- | ext/spl/spl_dllist.c | 19 | ||||
| -rw-r--r-- | ext/spl/spl_observer.c | 28 |
3 files changed, 27 insertions, 40 deletions
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 0c273a26b4..f6a38fb991 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -1710,7 +1710,7 @@ SPL_METHOD(Array, unserialize) size_t buf_len; const unsigned char *p, *s; php_unserialize_data_t var_hash; - zval members, zflags; + zval *members, *zflags; HashTable *aht; zend_long flags; @@ -1737,15 +1737,15 @@ SPL_METHOD(Array, unserialize) } ++p; - if (!php_var_unserialize(&zflags, &p, s + buf_len, &var_hash) || Z_TYPE(zflags) != IS_LONG) { + zflags = var_tmp_var(&var_hash); + if (!php_var_unserialize(zflags, &p, s + buf_len, &var_hash) || Z_TYPE_P(zflags) != IS_LONG) { goto outexcept; } - var_push_dtor(&var_hash, &zflags); --p; /* for ';' */ - flags = Z_LVAL(zflags); + flags = Z_LVAL_P(zflags); /* flags needs to be verified and we also need to verify whether the next - * thing we get is ';'. After that we require an 'm' or somethign else + * thing we get is ';'. After that we require an 'm' or something else * where 'm' stands for members and anything else should be an array. If * neither 'a' or 'm' follows we have an error. */ @@ -1777,19 +1777,15 @@ SPL_METHOD(Array, unserialize) } ++p; - ZVAL_UNDEF(&members); - if (!php_var_unserialize(&members, &p, s + buf_len, &var_hash) || Z_TYPE(members) != IS_ARRAY) { - zval_ptr_dtor(&members); + members = var_tmp_var(&var_hash); + if (!php_var_unserialize(members, &p, s + buf_len, &var_hash) || Z_TYPE_P(members) != IS_ARRAY) { goto outexcept; } - var_push_dtor(&var_hash, &members); /* copy members */ - object_properties_load(&intern->std, Z_ARRVAL(members)); - zval_ptr_dtor(&members); + object_properties_load(&intern->std, Z_ARRVAL_P(members)); /* done reading $serialized */ - PHP_VAR_UNSERIALIZE_DESTROY(var_hash); return; diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c index a0d6bf887e..210bcdff6e 100644 --- a/ext/spl/spl_dllist.c +++ b/ext/spl/spl_dllist.c @@ -1178,7 +1178,7 @@ SPL_METHOD(SplDoublyLinkedList, serialize) SPL_METHOD(SplDoublyLinkedList, unserialize) { spl_dllist_object *intern = Z_SPLDLLIST_P(getThis()); - zval flags, elem; + zval *flags, *elem; char *buf; size_t buf_len; const unsigned char *p, *s; @@ -1196,27 +1196,22 @@ SPL_METHOD(SplDoublyLinkedList, unserialize) PHP_VAR_UNSERIALIZE_INIT(var_hash); /* flags */ - if (!php_var_unserialize(&flags, &p, s + buf_len, &var_hash)) { + flags = var_tmp_var(&var_hash); + if (!php_var_unserialize(flags, &p, s + buf_len, &var_hash) || Z_TYPE_P(flags) != IS_LONG) { goto error; } - if (Z_TYPE(flags) != IS_LONG) { - zval_ptr_dtor(&flags); - goto error; - } - - intern->flags = (int)Z_LVAL(flags); - zval_ptr_dtor(&flags); + intern->flags = (int)Z_LVAL_P(flags); /* elements */ while(*p == ':') { ++p; - if (!php_var_unserialize(&elem, &p, s + buf_len, &var_hash)) { + elem = var_tmp_var(&var_hash); + if (!php_var_unserialize(elem, &p, s + buf_len, &var_hash)) { goto error; } - spl_ptr_llist_push(intern->llist, &elem); - zval_ptr_dtor(&elem); + spl_ptr_llist_push(intern->llist, elem); } if (*p != '\0') { diff --git a/ext/spl/spl_observer.c b/ext/spl/spl_observer.c index 315c0f8bcd..2796d3d93a 100644 --- a/ext/spl/spl_observer.c +++ b/ext/spl/spl_observer.c @@ -780,7 +780,8 @@ SPL_METHOD(SplObjectStorage, unserialize) size_t buf_len; const unsigned char *p, *s; php_unserialize_data_t var_hash; - zval entry, pmembers, pcount, inf; + zval entry, inf; + zval *pcount, *pmembers; spl_SplObjectStorageElement *element; zend_long count; @@ -801,17 +802,13 @@ SPL_METHOD(SplObjectStorage, unserialize) } ++p; - if (!php_var_unserialize(&pcount, &p, s + buf_len, &var_hash)) { - goto outexcept; - } - if (Z_TYPE(pcount) != IS_LONG) { - zval_ptr_dtor(&pcount); + pcount = var_tmp_var(&var_hash); + if (!php_var_unserialize(pcount, &p, s + buf_len, &var_hash) || Z_TYPE_P(pcount) != IS_LONG) { goto outexcept; } - var_push_dtor(&var_hash, &pcount); --p; /* for ';' */ - count = Z_LVAL(pcount); + count = Z_LVAL_P(pcount); while (count-- > 0) { spl_SplObjectStorageElement *pelement; @@ -824,7 +821,7 @@ SPL_METHOD(SplObjectStorage, unserialize) if(*p != 'O' && *p != 'C' && *p != 'r') { goto outexcept; } - /* sore reference to allow cross-references between different elements */ + /* store reference to allow cross-references between different elements */ if (!php_var_unserialize(&entry, &p, s + buf_len, &var_hash)) { goto outexcept; } @@ -838,6 +835,8 @@ SPL_METHOD(SplObjectStorage, unserialize) zval_ptr_dtor(&entry); goto outexcept; } + } else { + ZVAL_UNDEF(&inf); } hash = spl_object_storage_get_hash(intern, getThis(), &entry); @@ -856,7 +855,7 @@ SPL_METHOD(SplObjectStorage, unserialize) var_push_dtor(&var_hash, &pelement->obj); } } - element = spl_object_storage_attach(intern, getThis(), &entry, &inf); + element = spl_object_storage_attach(intern, getThis(), &entry, Z_ISUNDEF(inf)?NULL:&inf); var_replace(&var_hash, &entry, &element->obj); var_replace(&var_hash, &inf, &element->inf); zval_ptr_dtor(&entry); @@ -874,19 +873,16 @@ SPL_METHOD(SplObjectStorage, unserialize) } ++p; - ZVAL_UNDEF(&pmembers); - if (!php_var_unserialize(&pmembers, &p, s + buf_len, &var_hash) || Z_TYPE(pmembers) != IS_ARRAY) { - zval_ptr_dtor(&pmembers); + pmembers = var_tmp_var(&var_hash); + if (!php_var_unserialize(pmembers, &p, s + buf_len, &var_hash) || Z_TYPE_P(pmembers) != IS_ARRAY) { goto outexcept; } - var_push_dtor(&var_hash, &pmembers); /* copy members */ if (!intern->std.properties) { rebuild_object_properties(&intern->std); } - zend_hash_copy(intern->std.properties, Z_ARRVAL(pmembers), (copy_ctor_func_t) zval_add_ref); - zval_ptr_dtor(&pmembers); + zend_hash_copy(intern->std.properties, Z_ARRVAL_P(pmembers), (copy_ctor_func_t) zval_add_ref); PHP_VAR_UNSERIALIZE_DESTROY(var_hash); return; |
