]> granicus.if.org Git - php/commitdiff
Fix TimeZone leak in intl MessageFormat
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 25 Jun 2019 09:51:40 +0000 (11:51 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 25 Jun 2019 12:28:58 +0000 (14:28 +0200)
I'm just giving each format a distinct owned object here ... sharing
it looks complicated.

ext/intl/msgformat/msgformat_helpers.cpp

index dcc74283b22417ee2a9716ebb3b8db0212dc5500..ed75ae8bf687b4c9e86a0032630823abd787acc6 100644 (file)
@@ -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,