From: Michael Wallner Date: Fri, 10 Dec 2021 22:19:56 +0000 (+0100) Subject: immediately check for EOF X-Git-Tag: v0.1.0~84 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=7981a2e115a8e5b85d5becb7035d8e5ab76544da;p=awesomized%2Fext-ion immediately check for EOF --- 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); }