mirror of
https://github.com/php/php-src.git
synced 2026-04-28 10:43:30 +02:00
Fixed MemorySanitizer: use-of-uninitialized-value warning introduced by 932586c426
This commit is contained in:
+11
-7
@@ -2263,17 +2263,20 @@ PHPAPI zval *php_date_instantiate(zend_class_entry *pce, zval *object) /* {{{ */
|
||||
|
||||
/* Helper function used to store the latest found warnings and errors while
|
||||
* parsing, from either strtotime or parse_from_format. */
|
||||
static void update_errors_warnings(timelib_error_container *last_errors) /* {{{ */
|
||||
static timelib_error_container* update_errors_warnings(timelib_error_container **last_errors) /* {{{ */
|
||||
{
|
||||
if (DATEG(last_errors)) {
|
||||
timelib_error_container_dtor(DATEG(last_errors));
|
||||
DATEG(last_errors) = NULL;
|
||||
}
|
||||
if (last_errors->warning_count || last_errors->error_count) {
|
||||
DATEG(last_errors) = last_errors;
|
||||
} else {
|
||||
timelib_error_container_dtor(last_errors);
|
||||
|
||||
if ((*last_errors)->warning_count || (*last_errors)->error_count) {
|
||||
DATEG(last_errors) = *last_errors;
|
||||
return *last_errors;
|
||||
}
|
||||
|
||||
timelib_error_container_dtor(*last_errors);
|
||||
return NULL;
|
||||
} /* }}} */
|
||||
|
||||
static 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
|
||||
}
|
||||
|
||||
/* update last errors and warnings */
|
||||
update_errors_warnings(err);
|
||||
err = update_errors_warnings(&err);
|
||||
|
||||
/* If called from a constructor throw an exception */
|
||||
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) /* {{
|
||||
tmp_time = timelib_strtotime(modify, modify_len, &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
|
||||
|
||||
/* update last errors and warnings */
|
||||
update_errors_warnings(err);
|
||||
err = update_errors_warnings(&err);
|
||||
|
||||
if (err && err->error_count) {
|
||||
/* spit out the first library error message, at least */
|
||||
php_error_docref(NULL, E_WARNING, "Failed to parse time string (%s) at position %d (%c): %s", modify,
|
||||
|
||||
Reference in New Issue
Block a user