From 388127f1927ec6ba699a925969fd38a86cf56b3a Mon Sep 17 00:00:00 2001 From: sdefresne Date: Tue, 20 Sep 2016 08:53:14 -0700 Subject: [PATCH] Fix a memory leak reported by clang static analyzer. The CFStringCreateWithCString method respect the "Create Rule" [1] regarding the ownership of the returned reference. This means that the object needs 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=2354963002 Review-Url: https://codereview.chromium.org/2354963002 --- src/ports/SkOSFile_stdio.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ports/SkOSFile_stdio.cpp b/src/ports/SkOSFile_stdio.cpp index f008283804..6d39b3afd1 100644 --- a/src/ports/SkOSFile_stdio.cpp +++ b/src/ports/SkOSFile_stdio.cpp @@ -31,6 +31,7 @@ static FILE* ios_open_from_bundle(const char path[], const char* perm) { // Get a reference to the file's URL CFStringRef pathRef = CFStringCreateWithCString(NULL, path, kCFStringEncodingUTF8); CFURLRef imageURL = CFBundleCopyResourceURL(mainBundle, pathRef, NULL, NULL); + CFRelease(pathRef); if (!imageURL) { return nullptr; }