Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leak in CTFramesetterCreateWithAttributedString due to assignment (vs. attach) of ret->_typesetter #1754

Closed
jaredhms opened this issue Jan 20, 2017 · 0 comments

Comments

@jaredhms
Copy link
Contributor

This code leaks:

CTFramesetterRef CTFramesetterCreateWithAttributedString(CFAttributedStringRef string) {
    _CTFramesetter* ret = [_CTFramesetter alloc];
    ret->_typesetter = static_cast<_CTTypesetter*>(CTTypesetterCreateWithAttributedString(string));
    return static_cast<CTFramesetterRef>(ret);
}

Which causes runtime leaks when calculating font sizes in UIKit; for example:

Identifier Count Size (Bytes) Count Diff. Size Diff (Bytes) Module

  • -[UILabel intrinsicContentSize] 14 352 +14 +352 UIKIT.DLL
    • -[NSString(UIKitAdditions) sizeWithFont:] 14 352 +14 +352 UIKIT.DLL
      • -[NSString(UIKitAdditions) sizeWithFont:constrainedToSize:] 14 352 +14 +352 UIKIT.DLL
        • -[NSString(UIKitAdditions) _sizeWithAttributes:constrainedToSize:] 14 352 +14 +352 UIKIT.DLL
          • -[NSAttributedStringPrototype initWithString:attributes:] 12 320 +12 +320 FOUNDATION.DLL
            • CFAttributedStringCreate 12 320 +12 +320 COREFOUNDATION.DLL
              • CFDictionaryCreateMutableCopy 6 176 +6 +176 COREFOUNDATION.DLL
              • CFRunArrayCreate 4 112 +4 +112 COREFOUNDATION.DLL
              • _CFRuntimeCreateInstance 2 32 +2 +32 COREFOUNDATION.DLL
                • CFAllocatorAllocate 2 32 +2 +32 COREFOUNDATION.DLL
                  • __CFAllocatorSystemAllocate 2 32 +2 +32 COREFOUNDATION.DLL
                    [External Code] 2 32 +2 +32 [External Code]
          • CTFramesetterCreateWithAttributedString 2 32 +2 +32 CORETEXT.DLL
            • CTTypesetterCreateWithAttributedString 2 32 +2 +32 CORETEXT.DLL
              • +[NSObject alloc] 2 32 +2 +32 FOUNDATION.DLL
                • +[NSObject allocWithZone:] 2 32 +2 +32 FOUNDATION.DLL
                  • class_createInstance 2 32 +2 +32 LIBOBJC2.DLL
                    • allocate_class 2 32 +2 +32 LIBOBJC2.DLL
                      [External Code] 2 32 +2 +32 [External Code]

We should fix this and scrub the rest of the codebase for similar issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants