Skip to content

Commit b87bd71

Browse files
committed
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
1 parent 1a76e81 commit b87bd71

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

CoreFoundation/Locale.subproj/CFCalendar.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ Boolean _CFCalendarInitWithIdentifier(CFCalendarRef calendar, CFStringRef identi
249249

250250
calendar->_identifier = (CFStringRef)CFRetain(identifier);
251251
calendar->_locale = NULL;
252-
calendar->_localeID = CFLocaleGetIdentifier(CFLocaleGetSystem());
252+
calendar->_localeID = CFRetain(CFLocaleGetIdentifier(CFLocaleGetSystem()));
253253
calendar->_tz = CFTimeZoneCopyDefault();
254254
calendar->_cal = NULL;
255255
return true;
@@ -278,7 +278,7 @@ CFCalendarRef CFCalendarCreateWithIdentifier(CFAllocatorRef allocator, CFStringR
278278
}
279279
calendar->_identifier = (CFStringRef)CFRetain(identifier);
280280
calendar->_locale = NULL;
281-
calendar->_localeID = CFLocaleGetIdentifier(CFLocaleGetSystem());
281+
calendar->_localeID = CFRetain(CFLocaleGetIdentifier(CFLocaleGetSystem()));
282282
calendar->_tz = CFTimeZoneCopyDefault();
283283
calendar->_cal = NULL;
284284
return (CFCalendarRef)calendar;

0 commit comments

Comments
 (0)