immediately check for EOF
authorMichael Wallner <mike@php.net>
Fri, 10 Dec 2021 22:19:56 +0000 (23:19 +0100)
committerMichael Wallner <mike@php.net>
Tue, 14 Dec 2021 11:54:08 +0000 (12:54 +0100)
ion_private.h

index 7a3de5155481360e1bba00ba63f0df2192516c37..8c0ec60eadf7852423294aa4d5f261f8a882ab2f 100644 (file)
@@ -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);
        }