From: Nikita Popov Date: Tue, 25 Jun 2019 09:51:40 +0000 (+0200) Subject: Fix TimeZone leak in intl MessageFormat X-Git-Tag: php-7.4.0alpha3~192 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=77f7ec51521531bc84b4d9dc9bb6767c9f2aeb39;p=php Fix TimeZone leak in intl MessageFormat I'm just giving each format a distinct owned object here ... sharing it looks complicated. --- diff --git a/ext/intl/msgformat/msgformat_helpers.cpp b/ext/intl/msgformat/msgformat_helpers.cpp index dcc74283b2..ed75ae8bf6 100644 --- a/ext/intl/msgformat/msgformat_helpers.cpp +++ b/ext/intl/msgformat/msgformat_helpers.cpp @@ -343,20 +343,24 @@ static void umsg_set_timezone(MessageFormatter_object *mfo, } if (used_tz == NULL) { - zval nullzv, *zvptr = &nullzv; - ZVAL_NULL(zvptr); - used_tz = timezone_process_timezone_argument(zvptr, &err, "msgfmt_format"); + zval nullzv; + ZVAL_NULL(&nullzv); + used_tz = timezone_process_timezone_argument(&nullzv, &err, "msgfmt_format"); if (used_tz == NULL) { continue; } } - df->setTimeZone(*used_tz); + df->adoptTimeZone(used_tz->clone()); } if (U_SUCCESS(err.code)) { mfo->mf_data.tz_set = 1; } + + if (used_tz) { + delete used_tz; + } } U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo,