Skip to content

Commit 4744789

Browse files
committed
Merge branch 'PHP-8.2'
2 parents 5cb9e72 + 2d2a1e3 commit 4744789

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

ext/date/php_date.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2263,17 +2263,23 @@ 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 void 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 == NULL || (*last_errors) == NULL) {
2274+
return;
22762275
}
2276+
2277+
if ((*last_errors)->warning_count || (*last_errors)->error_count) {
2278+
DATEG(last_errors) = *last_errors;
2279+
}
2280+
2281+
timelib_error_container_dtor(*last_errors);
2282+
*last_errors = NULL;
22772283
} /* }}} */
22782284

22792285
static void php_date_set_time_fraction(timelib_time *time, int microseconds)
@@ -2324,7 +2330,7 @@ PHPAPI bool php_date_initialize(php_date_obj *dateobj, const char *time_str, siz
23242330
}
23252331

23262332
/* update last errors and warnings */
2327-
update_errors_warnings(err);
2333+
update_errors_warnings(&err);
23282334

23292335
/* If called from a constructor throw an exception */
23302336
if ((flags & PHP_DATE_INIT_CTOR) && err && err->error_count) {
@@ -3002,7 +3008,8 @@ static bool php_date_modify(zval *object, char *modify, size_t modify_len) /* {{
30023008
tmp_time = timelib_strtotime(modify, modify_len, &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
30033009

30043010
/* update last errors and warnings */
3005-
update_errors_warnings(err);
3011+
update_errors_warnings(&err);
3012+
30063013
if (err && err->error_count) {
30073014
/* spit out the first library error message, at least */
30083015
php_error_docref(NULL, E_WARNING, "Failed to parse time string (%s) at position %d (%c): %s", modify,

0 commit comments

Comments
 (0)