Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8117547

Potential leak in MacFontFinder.m

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 7u6
    • 7u6
    • javafx

      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.

            thor Thor Johannesson (Inactive)
            fheidric Felipe Heidrich (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: