We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Xcode 14.3, iOS 16.4
Into loadFontWithFileName func we call CTFontManagerRegisterGraphicsFont whitch have parameter with type CFErrorRef * which is not managed by ARC.
loadFontWithFileName
Proposed fix in RNVectorIconsManager.m:
To avoid memory leak we need to release that errorRef varible after usage.
RCT_EXPORT_METHOD(loadFontWithFileName:(NSString *)fontFileName extension:(NSString *)extension resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { NSBundle *bundle = [NSBundle bundleForClass:[self class]]; NSURL *fontURL = [bundle URLForResource:fontFileName withExtension:extension]; NSData *fontData = [NSData dataWithContentsOfURL:fontURL]; CGDataProviderRef provider = CGDataProviderCreateWithCFData((CFDataRef)fontData); CGFontRef font = CGFontCreateWithDataProvider(provider); if (font) { CFErrorRef errorRef = NULL; if (CTFontManagerRegisterGraphicsFont(font, &errorRef) == NO) { NSError *error = (__bridge NSError *)errorRef; if (error.code == kCTFontManagerErrorAlreadyRegistered) { resolve(nil); } else { reject(@"font_load_failed", @"Font failed to load", error); } } else { resolve(nil); } if (errorRef) { CFRelease(errorRef); } CFRelease(font); } if (provider) { CFRelease(provider); } }
Here we add
if (errorRef) { CFRelease(errorRef); }
Test project with memory leak https://github.com/kuserhii/ReactNativeVectorIconMemoryLeak
The text was updated successfully, but these errors were encountered:
Please open a PR 🙏
Sorry, something went wrong.
No branches or pull requests
Environment
Xcode 14.3, iOS 16.4
Description
Into
loadFontWithFileName
func we call CTFontManagerRegisterGraphicsFont whitch have parameter with type CFErrorRef * which is not managed by ARC.Proposed fix
Proposed fix in RNVectorIconsManager.m:
To avoid memory leak we need to release that errorRef varible after usage.
Here we add
Reproducible Demo
Test project with memory leak https://github.com/kuserhii/ReactNativeVectorIconMemoryLeak
The text was updated successfully, but these errors were encountered: