diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-08-26 10:10:41 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-08-26 10:24:57 +0200 |
commit | 72eaf509d3e56d3f4310243141f6df1aa4ae3427 (patch) | |
tree | 14838a4db321648f36624adb36e66b85b732a4c3 /ext/intl/calendar | |
parent | f6e5cc3391244d52267e8c3a69d3180279afea4f (diff) | |
download | php-git-72eaf509d3e56d3f4310243141f6df1aa4ae3427.tar.gz |
Prevent double-construction of IntlGregorianCalendar
Diffstat (limited to 'ext/intl/calendar')
-rw-r--r-- | ext/intl/calendar/gregoriancalendar_methods.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/ext/intl/calendar/gregoriancalendar_methods.cpp b/ext/intl/calendar/gregoriancalendar_methods.cpp index 84d594185c..64b7539789 100644 --- a/ext/intl/calendar/gregoriancalendar_methods.cpp +++ b/ext/intl/calendar/gregoriancalendar_methods.cpp @@ -85,8 +85,14 @@ static void _php_intlgregcal_constructor_body( } // instantion of ICU object + Calendar_object *co = Z_INTL_CALENDAR_P(return_value); GregorianCalendar *gcal = NULL; + if (co->ucal) { + zend_throw_error(NULL, "IntlGregorianCalendar object is already constructed"); + RETURN_THROWS(); + } + if (variant <= 2) { // From timezone and locale (0 to 2 arguments) TimeZone *tz = timezone_process_timezone_argument(tz_object, NULL, @@ -174,8 +180,7 @@ static void _php_intlgregcal_constructor_body( gcal->adoptTimeZone(tz); } - Calendar_object *co = Z_INTL_CALENDAR_P(return_value); - co->ucal = gcal; + co->ucal = gcal; } U_CFUNC PHP_FUNCTION(intlgregcal_create_instance) |