Fix memory leaks reported by clang static analyzer.
The CFURLCopyFileSystemPath & CFURLCopyFileSystemPath methods respect the "Create Rule" [1] regarding the ownership of the returned reference. This means that the objects need to be deallocated explicitly by calling CFRelease. [1]: https://developer.apple.com/library/content/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/Concepts/Ownership.html#//apple_ref/doc/uid/20001148-103029 BUG=648210 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2360573002 Review-Url: https://codereview.chromium.org/2360573002
This commit is contained in:
parent
2695eaa41f
commit
67ba29ce84
@ -38,14 +38,16 @@ static FILE* ios_open_from_bundle(const char path[], const char* perm) {
|
||||
|
||||
// Convert the URL reference into a string reference
|
||||
CFStringRef imagePath = CFURLCopyFileSystemPath(imageURL, kCFURLPOSIXPathStyle);
|
||||
CFRelease(imageURL);
|
||||
|
||||
// Get the system encoding method
|
||||
CFStringEncoding encodingMethod = CFStringGetSystemEncoding();
|
||||
|
||||
// Convert the string reference into a C string
|
||||
const char *finalPath = CFStringGetCStringPtr(imagePath, encodingMethod);
|
||||
|
||||
return fopen(finalPath, perm);
|
||||
FILE* fileHandle = fopen(finalPath, perm);
|
||||
CFRelease(imagePath);
|
||||
return fileHandle;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user