pokeb / asi-http-request

Easy to use CFNetwork wrapper for HTTP requests, Objective-C, Mac OS X and iPhone
http://allseeing-i.com/ASIHTTPRequest
Other
5.78k stars 1.41k forks source link

Memory leak in ASIHTTPRequest.m + (NSString *)defaultUserAgentString #214

Open deem0n opened 13 years ago

deem0n commented 13 years ago

easy to fix though:

diff --git a/Classes/ASIHTTPRequest.m b/Classes/ASIHTTPRequest.m
index 7c4f56f..2de5c88 100644
--- a/Classes/ASIHTTPRequest.m
+++ b/Classes/ASIHTTPRequest.m
@@ -4413,7 +4413,8 @@ static NSOperationQueue *sharedQueue = nil;
                        #endif

                        // Takes the form "My Application 1.0 (Macintosh; Mac OS X 10.5.7; en_GB)"
-                       [self setDefaultUserAgentString:[NSString stringWithFormat:@"%@ %@ (%@; %@ %@; %@)", appName, appV
+                       [self setDefaultUserAgentString:[NSString stringWithFormat:@"%@ %@ (%@; %@ %@; %@)", appName, appV
+            [appName release];
                }
                return [[defaultUserAgent retain] autorelease];
        }
Horse888 commented 13 years ago

Yes. I find the leak also.

pokeb commented 13 years ago

Maybe I'm missing something, but I can't see why appName should leak. Each of the instances where it is set give us an autoreleased string. I don't know if it used to leak and this was fixed a while ago, but as far as I can see it shouldn't now.

bengotow commented 12 years ago

Me either... this code looks fine. What versions of ASIHTTPRequest does this apply to?