From 51f2a5803fa4f09e212fed4b14ab8b4a003d4ef5 Mon Sep 17 00:00:00 2001 From: CHU Zhaowei Date: Sun, 11 Feb 2018 21:07:52 +0800 Subject: [PATCH] Fixed bug #68406 calling var_dump on a DateTimeZone object modifies it --- NEWS | 2 ++ ext/date/php_date.c | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 64906ed8df..4339ecf9e4 100644 --- a/NEWS +++ b/NEWS @@ -45,6 +45,8 @@ PHP NEWS . Implemented FR #74668: Add DateTime::createFromImmutable() method. (majkl578, Rican7) . Fixed bug #75222 (DateInterval microseconds property always 0). (jhdxr) + . Fixed bug #68406 (calling var_dump on a DateTimeZone object modifies it). + (jhdxr) - DBA: . Fixed bug #75264 (compiler warnings emitted). (petk) diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 9e52c071d6..df65c22b87 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -2417,9 +2417,9 @@ static HashTable *date_object_get_debug_info_timezone(zval *object, int *is_temp zend_string *tmpstr = zend_string_alloc(sizeof("UTC+05:00")-1, 0); ZSTR_LEN(tmpstr) = snprintf(ZSTR_VAL(tmpstr), sizeof("+05:00"), "%c%02d:%02d", - tzobj->tzi.utc_offset > 0 ? '-' : '+', - abs(tzobj->tzi.utc_offset / 60), - abs((tzobj->tzi.utc_offset % 60))); + tzobj->tzi.utc_offset < 0 ? '-' : '+', + abs((int)(tzobj->tzi.utc_offset / 3600)), + abs(((int)(tzobj->tzi.utc_offset % 3600) / 60))); ZVAL_NEW_STR(&zv, tmpstr); } -- 2.40.0