Skip to content

Commit

Permalink
Fix leaked return of CFUUIDCreate() (reported by clang static analyze…
Browse files Browse the repository at this point in the history
…r). Also make GC dual-mode safe by calling NSMakeCollectable() on return of CFUUIDCreateString()
  • Loading branch information
ddribin committed May 25, 2009
1 parent 15227df commit b1fb2b9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/NSURLRequest+postForm.m
Expand Up @@ -48,7 +48,13 @@ + (id)requestWithURL:(NSURL*)url postForm:(NSDictionary*)values {
// Create the mime multipart boundary.

// TODO scan `values` to ensure uniqueness of `boundary`. Loop+regen UUID if collision is discovered.
NSString *uuid = [(id)CFUUIDCreateString(kCFAllocatorDefault, CFUUIDCreate(kCFAllocatorDefault)) autorelease];
CFUUIDRef cfUuid = CFUUIDCreate(kCFAllocatorDefault);
NSString * uuid = (id)CFUUIDCreateString(kCFAllocatorDefault, cfUuid);
CFRelease(cfUuid);
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
uuid = NSMakeCollectable(uuid);
#endif
uuid = [uuid autorelease];
NSString *boundary = [NSString stringWithFormat:@"x-mime-boundary://%@", uuid];

//--
Expand Down

0 comments on commit b1fb2b9

Please sign in to comment.