@@ -823,6 +823,13 @@ static void uri_unserialize(INTERNAL_FUNCTION_PARAMETERS)
823823 ZEND_PARSE_PARAMETERS_END ();
824824
825825 zend_object * object = Z_OBJ_P (ZEND_THIS );
826+ uri_internal_t * internal_uri = uri_internal_from_obj (object );
827+ if (internal_uri -> uri != NULL ) {
828+ /* Intentionally throw two exceptions for proper chaining. */
829+ zend_throw_error (NULL , "Cannot modify readonly object of class %s" , ZSTR_VAL (object -> ce -> name ));
830+ zend_throw_exception_ex (NULL , 0 , "Invalid serialization data for %s object" , ZSTR_VAL (object -> ce -> name ));
831+ RETURN_THROWS ();
832+ }
826833
827834 /* Verify the expected number of elements, this implicitly ensures that no additional elements are present. */
828835 if (zend_hash_num_elements (data ) != 2 ) {
@@ -849,13 +856,6 @@ static void uri_unserialize(INTERNAL_FUNCTION_PARAMETERS)
849856 RETURN_THROWS ();
850857 }
851858
852- uri_internal_t * internal_uri = uri_internal_from_obj (object );
853- if (internal_uri -> uri != NULL ) {
854- /* Intentionally throw two exceptions for proper chaining. */
855- zend_throw_error (NULL , "Cannot modify readonly object of class %s" , ZSTR_VAL (Z_OBJCE_P (ZEND_THIS )-> name ));
856- zend_throw_exception_ex (NULL , 0 , "Invalid serialization data for %s object" , ZSTR_VAL (object -> ce -> name ));
857- RETURN_THROWS ();
858- }
859859 internal_uri -> uri = internal_uri -> parser -> parse (Z_STRVAL_P (uri_zv ), Z_STRLEN_P (uri_zv ), NULL , NULL , true);
860860 if (internal_uri -> uri == NULL ) {
861861 zend_throw_exception_ex (NULL , 0 , "Invalid serialization data for %s object" , ZSTR_VAL (object -> ce -> name ));
0 commit comments