Skip to content

Commit f799bc4

Browse files
committed
Don't return existing error_container/NULL, but use by-ref instead
1 parent 8cdfffb commit f799bc4

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

ext/date/php_date.c

+8-5
Original file line numberDiff line numberDiff line change
@@ -2263,20 +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 timelib_error_container* 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
}
22722272

2273+
if (last_errors == NULL || (*last_errors) == NULL) {
2274+
return;
2275+
}
2276+
22732277
if ((*last_errors)->warning_count || (*last_errors)->error_count) {
22742278
DATEG(last_errors) = *last_errors;
2275-
return *last_errors;
22762279
}
22772280

22782281
timelib_error_container_dtor(*last_errors);
2279-
return NULL;
2282+
*last_errors = NULL;
22802283
} /* }}} */
22812284

22822285
static void php_date_set_time_fraction(timelib_time *time, int microseconds)
@@ -2327,7 +2330,7 @@ PHPAPI bool php_date_initialize(php_date_obj *dateobj, const char *time_str, siz
23272330
}
23282331

23292332
/* update last errors and warnings */
2330-
err = update_errors_warnings(&err);
2333+
update_errors_warnings(&err);
23312334

23322335
/* If called from a constructor throw an exception */
23332336
if ((flags & PHP_DATE_INIT_CTOR) && err && err->error_count) {
@@ -3005,7 +3008,7 @@ static bool php_date_modify(zval *object, char *modify, size_t modify_len) /* {{
30053008
tmp_time = timelib_strtotime(modify, modify_len, &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
30063009

30073010
/* update last errors and warnings */
3008-
err = update_errors_warnings(&err);
3011+
update_errors_warnings(&err);
30093012

30103013
if (err && err->error_count) {
30113014
/* spit out the first library error message, at least */

0 commit comments

Comments
 (0)