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

Potential leak in MacFontFinder.m

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 7u6
    • Fix Version/s: 7u6
    • Component/s: javafx
    • Labels:

      Description

      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.

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: