summaryrefslogtreecommitdiff
path: root/ext/date/php_date.c
diff options
context:
space:
mode:
authorDerick Rethans <github@derickrethans.nl>2019-02-28 13:52:33 +0000
committerDerick Rethans <github@derickrethans.nl>2019-02-28 13:52:33 +0000
commit9624e87a8fb4a3ae99bd6ed2cda6bd953ce3d98c (patch)
tree6e966c8d0bacb756c6acc7816c19469cb0d5c559 /ext/date/php_date.c
parent9d356bab503c0875d577ab5c19638559549ea9f7 (diff)
parentd63a7aa6cfb549f3462be9f0a05bad80a59d20a0 (diff)
downloadphp-git-9624e87a8fb4a3ae99bd6ed2cda6bd953ce3d98c.tar.gz
Merge branch 'PHP-7.3' into PHP-7.4
Diffstat (limited to 'ext/date/php_date.c')
-rw-r--r--ext/date/php_date.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 8bb310f2a7..a882071835 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -4435,12 +4435,21 @@ PHP_FUNCTION(date_interval_create_from_date_string)
Z_PARAM_STR(time_str)
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
- php_date_instantiate(date_ce_interval, return_value);
-
time = timelib_strtotime(ZSTR_VAL(time_str), ZSTR_LEN(time_str), &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
+
+ if (err->error_count > 0) {
+ php_error_docref(NULL, E_WARNING, "Unknown or bad format (%s) at position %d (%c): %s", ZSTR_VAL(time_str),
+ err->error_messages[0].position, err->error_messages[0].character ? err->error_messages[0].character : ' ', err->error_messages[0].message);
+ RETVAL_FALSE;
+ goto cleanup;
+ }
+
+ php_date_instantiate(date_ce_interval, return_value);
diobj = Z_PHPINTERVAL_P(return_value);
diobj->diff = timelib_rel_time_clone(&time->relative);
diobj->initialized = 1;
+
+cleanup:
timelib_time_dtor(time);
timelib_error_container_dtor(err);
}