aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports
diff options
context:
space:
mode:
authorGravatar sdefresne <sdefresne@chromium.org>2016-09-21 06:51:33 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-09-21 06:51:33 -0700
commit67ba29ce84c464270e8f4ccca6c22d37882a90f4 (patch)
treec80406da1a6bd296855d8164cfb98537c492c35a /src/ports
parent2695eaa41fbd208dcee9e134e180c6609856f0ac (diff)
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
Diffstat (limited to 'src/ports')
-rw-r--r--src/ports/SkOSFile_stdio.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/ports/SkOSFile_stdio.cpp b/src/ports/SkOSFile_stdio.cpp
index 6d39b3afd1..1c4bd4babd 100644
--- a/src/ports/SkOSFile_stdio.cpp
+++ b/src/ports/SkOSFile_stdio.cpp
@@ -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