From 7981a2e115a8e5b85d5becb7035d8e5ab76544da Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Fri, 10 Dec 2021 23:19:56 +0100 Subject: [PATCH] immediately check for EOF --- ion_private.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/ion_private.h b/ion_private.h index 7a3de51..8c0ec60 100644 --- a/ion_private.h +++ b/ion_private.h @@ -1402,6 +1402,10 @@ static inline void php_ion_unserialize_hash(php_ion_unserializer *ser, zval *ret ION_TYPE typ; ION_CHECK(ion_reader_next(ser->reader, &typ)); + if (typ == tid_EOF) { + break; + } + ION_STRING name; ION_CHECK(ion_reader_get_field_name(ser->reader, &name)); zend_string *key = zend_string_from_ion(&name); @@ -1410,11 +1414,6 @@ static inline void php_ion_unserialize_hash(php_ion_unserializer *ser, zval *ret php_ion_unserialize_zval(ser, &zvalue, &typ); ION_CATCH(zend_string_release(key)); - if (typ == tid_EOF) { - zend_string_release(key); - break; - } - zend_symtable_update(HASH_OF(return_value), key, &zvalue); zend_string_release(key); @@ -1519,14 +1518,14 @@ static inline void php_ion_unserialize_list(php_ion_unserializer *ser, zval *ret ION_TYPE typ; ION_CHECK(ion_reader_next(ser->reader, &typ)); - zval next; - php_ion_unserialize_zval(ser, &next, &typ); - ION_CATCH(); - if (typ == tid_EOF) { break; } + zval next; + php_ion_unserialize_zval(ser, &next, &typ); + ION_CATCH(); + zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &next); } -- 2.30.2