From 81b63af3c7aad9dbb7ab0e5ef0c7bbe69ac0e75d Mon Sep 17 00:00:00 2001 From: rfm Date: Thu, 30 Oct 2014 09:55:40 +0000 Subject: [PATCH] Fix for bug #43461 by Sergei Golovin git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@38140 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 5 +++++ Source/NSURLProtocol.m | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/ChangeLog b/ChangeLog index 8a0cb1ad7..acd167615 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-10-30 Sergei Golovin + + * Source/NSURLProtocol.m: Fix memory leak and possible hang on retry + (bug #43461). + 2014-10-17 Richard Frith-Macdonald * Documentation/news.texi: diff --git a/Source/NSURLProtocol.m b/Source/NSURLProtocol.m index 398b0ec9b..107fbb216 100644 --- a/Source/NSURLProtocol.m +++ b/Source/NSURLProtocol.m @@ -1579,6 +1579,17 @@ static NSURLProtocol *placeholder = nil; buffer + written length: len]; _writeOffset = 0; } + else if (len == 0 && ![_body hasBytesAvailable]) + { + /* all _body's bytes are read and written + * so we shouldn't wait for another + * opportunity to close _body and set + * the flag 'sent'. + */ + [_body close]; + DESTROY(_body); + sent = YES; + } } else if ([this->output streamStatus] == NSStreamStatusWriting)