Skip to content

Commit

Permalink
Fix leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
rfm committed Nov 29, 2024
1 parent e6b425d commit 818041d
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions Source/NSURLProtocol.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#import "Foundation/NSHost.h"
#import "Foundation/NSNotification.h"
#import "Foundation/NSRunLoop.h"
#import "Foundation/NSSet.h"
#import "Foundation/NSValue.h"

#if GS_HAVE_NSURLSESSION
Expand Down Expand Up @@ -485,7 +486,6 @@ + (void) atExit
placeholder = nil;
NSDeallocateObject(o);
}
fprintf(stderr, "Registered retain count %d\n", (int)[registered retainCount]);
DESTROY(registered);
DESTROY(regLock);
}
Expand Down Expand Up @@ -811,18 +811,19 @@ - (void) continueWithoutCredentialForAuthenticationChallenge:

- (void) dealloc
{
[_parser release]; // received headers
[_body release]; // for sending the body
[_response release];
[_credential release];
DESTROY(_parser); // received headers
DESTROY(_body); // for sending the body
DESTROY(_response);
DESTROY(_challenge);
DESTROY(_credential);
DESTROY(_writeData);
DESTROY(_masked);
[super dealloc];
}

- (void) startLoading
{
static NSDictionary *methods = nil;
static NSSet *methods = nil;

_debug = GSDebugSet(@"NSURLProtocol");
if (YES == [this->request _debug])
Expand All @@ -836,18 +837,18 @@ - (void) startLoading

if (methods == nil)
{
methods = [[NSDictionary alloc] initWithObjectsAndKeys:
self, @"HEAD",
self, @"GET",
self, @"POST",
self, @"PUT",
self, @"DELETE",
self, @"TRACE",
self, @"OPTIONS",
self, @"CONNECT",
methods = [[NSSet alloc] initWithObjects:
@"HEAD",
@"GET",
@"POST",
@"PUT",
@"DELETE",
@"TRACE",
@"OPTIONS",
@"CONNECT",
nil];
}
if ([methods objectForKey: [this->request HTTPMethod]] == nil)
if ([methods member: [this->request HTTPMethod]] == nil)
{
NSLog(@"Invalid HTTP Method: %@", this->request);
[self stopLoading];
Expand Down Expand Up @@ -1042,6 +1043,8 @@ - (void) stopLoading
_isLoading = NO;
DESTROY(_writeData);
DESTROY(_masked);
DESTROY(_challenge);
DESTROY(_credential);
if (this->input != nil)
{
[this->input setDelegate: nil];
Expand Down Expand Up @@ -1179,6 +1182,7 @@ - (void) _got: (NSStream*)stream
{
ct = nil;
}
DESTROY(_response);
_response = [[NSHTTPURLResponse alloc]
initWithURL: [this->request URL]
MIMEType: ct
Expand Down

0 comments on commit 818041d

Please sign in to comment.