Permalink
Browse files

[cleanedAgent bytes] is not null-terminated so stringWithCString prod…

…uces a bad NSString. use initWithData instead.
  • Loading branch information...
1 parent 6397e56 commit d1c54608f77146e9b3a4c2ade5bbd5f5addfdf45 @j3r3miah j3r3miah committed May 9, 2009
Showing with 1 addition and 1 deletion.
  1. +1 −1 SUBasicUpdateDriver.m
View
@@ -32,7 +32,7 @@ - (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)aHost
[appcast setDelegate:self];
NSString *userAgent = [NSString stringWithFormat: @"%@/%@ Sparkle/%@", [aHost name], [aHost displayVersion], ([SPARKLE_BUNDLE objectForInfoDictionaryKey:@"CFBundleVersion"] ?: nil)];
NSData * cleanedAgent = [userAgent dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
- userAgent = [NSString stringWithCString:[cleanedAgent bytes] encoding:NSASCIIStringEncoding];
+ userAgent = [[[NSString alloc] initWithData:cleanedAgent encoding:NSASCIIStringEncoding] autorelease];
[appcast setUserAgentString:userAgent];
[appcast fetchAppcastFromURL:URL];
}

0 comments on commit d1c5460

Please sign in to comment.