diff options
author | Anatol Belski <ab@php.net> | 2018-08-09 22:09:21 +0200 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2018-08-09 22:09:21 +0200 |
commit | 3cef5a2476176ce32e22eb49091718489f4f8872 (patch) | |
tree | 139c4c727adb0b2f59d112ef0679fbc4fb94f140 /ext/intl/msgformat/msgformat_helpers.cpp | |
parent | d22ddd8cf12b5582b11dcba84d93f1b558ce30ae (diff) | |
parent | 9cc74ba229aa5c605acb66e7b96c4a1291f7ce1e (diff) | |
download | php-git-3cef5a2476176ce32e22eb49091718489f4f8872.tar.gz |
Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
Fixed bug #74484 MessageFormatter::formatMessage memory corruption
Diffstat (limited to 'ext/intl/msgformat/msgformat_helpers.cpp')
-rw-r--r-- | ext/intl/msgformat/msgformat_helpers.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/ext/intl/msgformat/msgformat_helpers.cpp b/ext/intl/msgformat/msgformat_helpers.cpp index a3005ded3b..7d307ccc0c 100644 --- a/ext/intl/msgformat/msgformat_helpers.cpp +++ b/ext/intl/msgformat/msgformat_helpers.cpp @@ -27,6 +27,7 @@ #include <unicode/timezone.h> #include <unicode/datefmt.h> #include <unicode/calendar.h> +#include <unicode/strenum.h> #include <vector> @@ -333,6 +334,24 @@ static void umsg_set_timezone(MessageFormatter_object *mfo, return; /* already done */ } + /* There is a bug in ICU which prevents MessageFormatter::getFormats() + to handle more than 10 formats correctly. The enumerator could be + used to walk through the present formatters using getFormat(), which + however seems to provide just a readonly access. This workaround + prevents crash when there are > 10 formats but doesn't set any error. + As a result, only DateFormatters with > 10 subformats are affected. + This workaround should be ifdef'd out, when the bug has been fixed + in ICU. */ + icu::StringEnumeration* fnames = mf->getFormatNames(err.code); + if (!fnames || U_FAILURE(err.code)) { + return; + } + count = fnames->count(err.code); + delete fnames; + if (count > 10) { + return; + } + formats = mf->getFormats(count); if (formats == NULL) { |