@@ -2263,17 +2263,20 @@ PHPAPI zval *php_date_instantiate(zend_class_entry *pce, zval *object) /* {{{ */
22632263
22642264/* Helper function used to store the latest found warnings and errors while
22652265 * parsing, from either strtotime or parse_from_format. */
2266- static void update_errors_warnings (timelib_error_container * last_errors ) /* {{{ */
2266+ static timelib_error_container * update_errors_warnings (timelib_error_container * * last_errors ) /* {{{ */
22672267{
22682268 if (DATEG (last_errors )) {
22692269 timelib_error_container_dtor (DATEG (last_errors ));
22702270 DATEG (last_errors ) = NULL ;
22712271 }
2272- if ( last_errors -> warning_count || last_errors -> error_count ) {
2273- DATEG ( last_errors ) = last_errors ;
2274- } else {
2275- timelib_error_container_dtor ( last_errors ) ;
2272+
2273+ if (( * last_errors )-> warning_count || ( * last_errors ) -> error_count ) {
2274+ DATEG ( last_errors ) = * last_errors ;
2275+ return * last_errors ;
22762276 }
2277+
2278+ timelib_error_container_dtor (* last_errors );
2279+ return NULL ;
22772280} /* }}} */
22782281
22792282static void php_date_set_time_fraction (timelib_time * time , int microseconds )
@@ -2324,7 +2327,7 @@ PHPAPI bool php_date_initialize(php_date_obj *dateobj, const char *time_str, siz
23242327 }
23252328
23262329 /* update last errors and warnings */
2327- update_errors_warnings (err );
2330+ err = update_errors_warnings (& err );
23282331
23292332 /* If called from a constructor throw an exception */
23302333 if ((flags & PHP_DATE_INIT_CTOR ) && err && err -> error_count ) {
@@ -3002,7 +3005,8 @@ static bool php_date_modify(zval *object, char *modify, size_t modify_len) /* {{
30023005 tmp_time = timelib_strtotime (modify , modify_len , & err , DATE_TIMEZONEDB , php_date_parse_tzfile_wrapper );
30033006
30043007 /* update last errors and warnings */
3005- update_errors_warnings (err );
3008+ err = update_errors_warnings (& err );
3009+
30063010 if (err && err -> error_count ) {
30073011 /* spit out the first library error message, at least */
30083012 php_error_docref (NULL , E_WARNING , "Failed to parse time string (%s) at position %d (%c): %s" , modify ,
0 commit comments