From b87bd7152ca9b235af338e993fa4e86acafa32e8 Mon Sep 17 00:00:00 2001 From: Alex Blewitt Date: Fri, 7 Oct 2016 11:56:05 +0100 Subject: [PATCH] Retain localeID when constructing a Calendar The Calendar destructor releases stored values when the Calendar is being deallocated, including releasing the localeID. By default this is an empty string (kCFEmptyString) which results in multiple Calendars causing a fault when it is over-released. Ensure that instead the localeID is retained to balance the release when it is cleaned up. Issue: SR-2879 --- CoreFoundation/Locale.subproj/CFCalendar.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CoreFoundation/Locale.subproj/CFCalendar.c b/CoreFoundation/Locale.subproj/CFCalendar.c index dd3f9d935e..6e68bd270a 100644 --- a/CoreFoundation/Locale.subproj/CFCalendar.c +++ b/CoreFoundation/Locale.subproj/CFCalendar.c @@ -249,7 +249,7 @@ Boolean _CFCalendarInitWithIdentifier(CFCalendarRef calendar, CFStringRef identi calendar->_identifier = (CFStringRef)CFRetain(identifier); calendar->_locale = NULL; - calendar->_localeID = CFLocaleGetIdentifier(CFLocaleGetSystem()); + calendar->_localeID = CFRetain(CFLocaleGetIdentifier(CFLocaleGetSystem())); calendar->_tz = CFTimeZoneCopyDefault(); calendar->_cal = NULL; return true; @@ -278,7 +278,7 @@ CFCalendarRef CFCalendarCreateWithIdentifier(CFAllocatorRef allocator, CFStringR } calendar->_identifier = (CFStringRef)CFRetain(identifier); calendar->_locale = NULL; - calendar->_localeID = CFLocaleGetIdentifier(CFLocaleGetSystem()); + calendar->_localeID = CFRetain(CFLocaleGetIdentifier(CFLocaleGetSystem())); calendar->_tz = CFTimeZoneCopyDefault(); calendar->_cal = NULL; return (CFCalendarRef)calendar;