-
Bug
-
Resolution: Fixed
-
P4
-
7u6
Find the method getXFromFontFile(), look for this code:
for (i = 0; i < urlCount; i++) {
fontURLPath = (*env)->GetObjectArrayElement(env, fontURLPaths, i);
path = JavaStringToNSString(env, fontURLPath);
fontURL = [[[NSURL alloc] initWithString:path] autorelease];
fontDescArray = CTFontManagerCreateFontDescriptorsFromURL((CFURLRef)fontURL);
arySize = CFArrayGetCount(fontDescArray);
k = 0;
for (k = 0; k < arySize; k++) {
NSString *attribute = (NSString*)CTFontDescriptorCopyAttribute(CFArrayGetValueAtIndex(fontDescArray, k), x);
[nsRet addObject:attribute];
[attribute release];
}
}
CFRelease(fontDescArray);
According to the doc http://developer.apple.com/library/mac/#documentation/Carbon/Reference/CoreText_FontManager_Ref/Reference/reference.html
the caller of CTFontManagerCreateFontDescriptorsFromURL() is responsible for releasing the array.
Therefore the call to CFRelease(fontDescArray); should be inside of the for loop, not after (in which case only the last array is getting freed).
The format (indent) of the code is also a bit wrong, please fix.
for (i = 0; i < urlCount; i++) {
fontURLPath = (*env)->GetObjectArrayElement(env, fontURLPaths, i);
path = JavaStringToNSString(env, fontURLPath);
fontURL = [[[NSURL alloc] initWithString:path] autorelease];
fontDescArray = CTFontManagerCreateFontDescriptorsFromURL((CFURLRef)fontURL);
arySize = CFArrayGetCount(fontDescArray);
k = 0;
for (k = 0; k < arySize; k++) {
NSString *attribute = (NSString*)CTFontDescriptorCopyAttribute(CFArrayGetValueAtIndex(fontDescArray, k), x);
[nsRet addObject:attribute];
[attribute release];
}
}
CFRelease(fontDescArray);
According to the doc http://developer.apple.com/library/mac/#documentation/Carbon/Reference/CoreText_FontManager_Ref/Reference/reference.html
the caller of CTFontManagerCreateFontDescriptorsFromURL() is responsible for releasing the array.
Therefore the call to CFRelease(fontDescArray); should be inside of the for loop, not after (in which case only the last array is getting freed).
The format (indent) of the code is also a bit wrong, please fix.