From 2c34864a06f31d1d909f7abe62d8047409fe9f00 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Tue, 26 Jul 2016 13:01:09 +0600 Subject: CLOUD: Fix UploadFileClientHandler A few possible memory leaks about `_contentStream` there. --- backends/networking/sdl_net/uploadfileclienthandler.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'backends/networking/sdl_net') diff --git a/backends/networking/sdl_net/uploadfileclienthandler.cpp b/backends/networking/sdl_net/uploadfileclienthandler.cpp index 048ff39810..e2832bcba5 100644 --- a/backends/networking/sdl_net/uploadfileclienthandler.cpp +++ b/backends/networking/sdl_net/uploadfileclienthandler.cpp @@ -137,6 +137,12 @@ void UploadFileClientHandler::handleBlockHeaders(Client *client) { return; } + // remove previous stream (if there is one) + if (_contentStream) { + delete _contentStream; + _contentStream = nullptr; + } + // create file stream (and necessary subdirectories) Common::DumpFile *f = new Common::DumpFile(); if (!f->open(originalNode->getPath(), true)) { @@ -156,6 +162,9 @@ void UploadFileClientHandler::handleBlockContent(Client *client) { _contentStream->flush(); ++_uploadedFiles; + delete _contentStream; + _contentStream = nullptr; + if (client->noMoreContent()) { // success - redirect back to directory listing HandlerUtils::setMessageHandler( -- cgit v1.2.3