memory problem fix

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@25145 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2007-05-12 06:29:57 +00:00
parent 3a7e91dc7e
commit 37f9a1410b
3 changed files with 16 additions and 12 deletions

View file

@ -1,3 +1,7 @@
2007-05-12 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSURLProtocol.m: Fix multiple release of headers.
2007-05-11 Richard Frith-Macdonald <rfm@gnu.org> 2007-05-11 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSStream.m: * Source/GSStream.m:

View file

@ -364,7 +364,7 @@ static NSURLProtocol *placeholder = nil;
outputStream: &this->output]; outputStream: &this->output];
if (!this->input || !this->output) if (!this->input || !this->output)
{ {
#if 1 #if 0
NSLog(@"did not create streams for %@: %u", host, [[url port] intValue]); NSLog(@"did not create streams for %@: %u", host, [[url port] intValue]);
#endif #endif
[this->client URLProtocol: self didFailWithError: [this->client URLProtocol: self didFailWithError:
@ -397,7 +397,7 @@ static NSURLProtocol *placeholder = nil;
- (void) stopLoading - (void) stopLoading
{ {
#if 1 #if 0
NSLog(@"stopLoading: %@", self); NSLog(@"stopLoading: %@", self);
#endif #endif
if (this->input != nil) if (this->input != nil)
@ -423,7 +423,7 @@ static NSURLProtocol *placeholder = nil;
{ // process header line { // process header line
unsigned char *c, *end; unsigned char *c, *end;
NSString *key, *val; NSString *key, *val;
#if 1 #if 0
NSLog(@"process header line len=%d", len); NSLog(@"process header line len=%d", len);
#endif #endif
// if it begins with ' ' or '\t' it is a continuation line to the previous header field // if it begins with ' ' or '\t' it is a continuation line to the previous header field
@ -435,7 +435,7 @@ static NSURLProtocol *placeholder = nil;
if (major != 1 || minor > 1) if (major != 1 || minor > 1)
[this->client URLProtocol: self didFailWithError: [NSError errorWithDomain: @"Bad HTTP version" code: 0 userInfo: nil]]; [this->client URLProtocol: self didFailWithError: [NSError errorWithDomain: @"Bad HTTP version" code: 0 userInfo: nil]];
// must be first - but must also be present and valid before we go to receive the body! // must be first - but must also be present and valid before we go to receive the body!
_headers=[NSMutableDictionary dictionaryWithCapacity: 10]; // start collecting headers _headers=[NSMutableDictionary new]; // start collecting headers
// if (_statusCode >= 400 && _statusCode <= 499) // if (_statusCode >= 400 && _statusCode <= 499)
NSLog(@"Client header: %.*s", len, buffer); NSLog(@"Client header: %.*s", len, buffer);
return NO; // process next line return NO; // process next line
@ -499,7 +499,7 @@ NSLog(@"Received");
- (void) _processHeader: (unsigned char *) buffer length: (int) len - (void) _processHeader: (unsigned char *) buffer length: (int) len
{ // next header fragment received { // next header fragment received
unsigned char *ptr, *end; unsigned char *ptr, *end;
#if 1 #if 0
NSLog(@"received %d bytes", len); NSLog(@"received %d bytes", len);
#endif #endif
if (len <= 0) if (len <= 0)
@ -570,7 +570,7 @@ NSLog(@"Received");
#endif #endif
if (stream == this->input) if (stream == this->input)
{ {
#if 1 #if 0
NSLog(@"input stream handleEvent: %x for: %@", event, self); NSLog(@"input stream handleEvent: %x for: %@", event, self);
#endif #endif
switch(event) switch(event)
@ -584,7 +584,7 @@ NSLog(@"Received");
maxLength: sizeof(buffer)]; maxLength: sizeof(buffer)];
if (len < 0) if (len < 0)
{ {
#if 1 #if 0
NSLog(@"receive error %@", [NSError _last]); NSLog(@"receive error %@", [NSError _last]);
#endif #endif
[this->client URLProtocol: self didFailWithError: [NSError errorWithDomain: @"receive error" code: 0 userInfo: nil]]; [this->client URLProtocol: self didFailWithError: [NSError errorWithDomain: @"receive error" code: 0 userInfo: nil]];
@ -599,7 +599,7 @@ NSLog(@"Received");
} }
case NSStreamEventEndEncountered: // can this occur in parallel to NSStreamEventHasBytesAvailable??? case NSStreamEventEndEncountered: // can this occur in parallel to NSStreamEventHasBytesAvailable???
{ {
#if 1 #if 0
NSLog(@"end of response"); NSLog(@"end of response");
#endif #endif
if (!_readingBody) if (!_readingBody)
@ -611,7 +611,7 @@ NSLog(@"Received");
} }
case NSStreamEventOpenCompleted: case NSStreamEventOpenCompleted:
{ // prepare to receive header { // prepare to receive header
#if 1 #if 0
NSLog(@"HTTP input stream opened"); NSLog(@"HTTP input stream opened");
#endif #endif
return; return;
@ -644,7 +644,7 @@ NSLog(@"Received");
NSLog(@"HTTP output stream opened"); NSLog(@"HTTP output stream opened");
#endif #endif
msg = (unsigned char *)[[NSString stringWithFormat: msg = (unsigned char *)[[NSString stringWithFormat:
@"%@ %@ HTTP/1.1\r\n", @"%@ %@ HTTP/1.0\r\n",
[this->request HTTPMethod], [this->request HTTPMethod],
[[this->request URL] absoluteString]] UTF8String]; [[this->request URL] absoluteString]] UTF8String];
[(NSOutputStream *) stream write: msg [(NSOutputStream *) stream write: msg
@ -693,7 +693,7 @@ NSLog(@"Received");
int len=[_body read: buffer maxLength: sizeof(buffer)]; // read next block from stream int len=[_body read: buffer maxLength: sizeof(buffer)]; // read next block from stream
if (len < 0) if (len < 0)
{ {
#if 1 #if 0
NSLog(@"error reading from HTTPBody stream %@", [NSError _last]); NSLog(@"error reading from HTTPBody stream %@", [NSError _last]);
#endif #endif
[self _unschedule]; [self _unschedule];

View file

@ -611,7 +611,7 @@ static void setNonblocking(int fd)
if (len == 0) if (len == 0)
{ {
[NSException raise: NSInvalidArgumentException [NSException raise: NSInvalidArgumentException
format: @"zero byte read write requested"]; format: @"zero byte read requested"];
} }
_events &= ~NSStreamEventHasBytesAvailable; _events &= ~NSStreamEventHasBytesAvailable;