Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: src/ports/SkOSFile_stdio.cpp

Issue 2360573002: Fix memory leaks reported by clang static analyzer. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkOSFile.h" 8 #include "SkOSFile.h"
9 #include "SkTypes.h" 9 #include "SkTypes.h"
10 10
(...skipping 20 matching lines...) Expand all
31 // Get a reference to the file's URL 31 // Get a reference to the file's URL
32 CFStringRef pathRef = CFStringCreateWithCString(NULL, path, kCFStringEncodin gUTF8); 32 CFStringRef pathRef = CFStringCreateWithCString(NULL, path, kCFStringEncodin gUTF8);
33 CFURLRef imageURL = CFBundleCopyResourceURL(mainBundle, pathRef, NULL, NULL) ; 33 CFURLRef imageURL = CFBundleCopyResourceURL(mainBundle, pathRef, NULL, NULL) ;
34 CFRelease(pathRef); 34 CFRelease(pathRef);
35 if (!imageURL) { 35 if (!imageURL) {
36 return nullptr; 36 return nullptr;
37 } 37 }
38 38
39 // Convert the URL reference into a string reference 39 // Convert the URL reference into a string reference
40 CFStringRef imagePath = CFURLCopyFileSystemPath(imageURL, kCFURLPOSIXPathSty le); 40 CFStringRef imagePath = CFURLCopyFileSystemPath(imageURL, kCFURLPOSIXPathSty le);
41 CFRelease(imageURL);
41 42
42 // Get the system encoding method 43 // Get the system encoding method
43 CFStringEncoding encodingMethod = CFStringGetSystemEncoding(); 44 CFStringEncoding encodingMethod = CFStringGetSystemEncoding();
44 45
45 // Convert the string reference into a C string 46 // Convert the string reference into a C string
46 const char *finalPath = CFStringGetCStringPtr(imagePath, encodingMethod); 47 const char *finalPath = CFStringGetCStringPtr(imagePath, encodingMethod);
47 48 FILE* fileHandle = fopen(finalPath, perm);
48 return fopen(finalPath, perm); 49 CFRelease(imagePath);
50 return fileHandle;
49 } 51 }
50 #endif 52 #endif
51 53
52 54
53 FILE* sk_fopen(const char path[], SkFILE_Flags flags) { 55 FILE* sk_fopen(const char path[], SkFILE_Flags flags) {
54 char perm[4]; 56 char perm[4];
55 char* p = perm; 57 char* p = perm;
56 58
57 if (flags & kRead_SkFILE_Flag) { 59 if (flags & kRead_SkFILE_Flag) {
58 *p++ = 'r'; 60 *p++ = 'r';
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 #else 206 #else
205 retval = mkdir(path, 0777); 207 retval = mkdir(path, 0777);
206 #endif 208 #endif
207 if (0 == retval) { 209 if (0 == retval) {
208 return true; 210 return true;
209 } else { 211 } else {
210 fprintf(stderr, "sk_mkdir: error %d creating dir '%s'\n", errno, path); 212 fprintf(stderr, "sk_mkdir: error %d creating dir '%s'\n", errno, path);
211 return false; 213 return false;
212 } 214 }
213 } 215 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698