diff options
author | Tobias Markmann <tm@ayena.de> | 2015-07-16 07:45:52 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2015-07-16 07:45:52 (GMT) |
commit | 382bce69ae2e94a2b9635a0be6db93a6ecd4ddce (patch) | |
tree | bab5e32775850da033313e74d7683da10c896d0b /Swiften/FileTransfer/FileWriteBytestream.cpp | |
parent | 2c8a390256a9ef0c0d8c6c930594a68d8f6d2072 (diff) | |
download | swift-382bce69ae2e94a2b9635a0be6db93a6ecd4ddce.zip swift-382bce69ae2e94a2b9635a0be6db93a6ecd4ddce.tar.bz2 |
Fix memory leaks in FileReadBytestream and FileWriteBytestream
Reported by LSAN.
Test-Information:
Detected by running FileTransferTest with LSAN on Linux.
The leak reports for the allocations in FileReadBytestream and
FileWriteBytestream are gone with this fix.
Change-Id: I32711990eca0c9a2a2982837cfac38cb11a28caa
Diffstat (limited to 'Swiften/FileTransfer/FileWriteBytestream.cpp')
-rw-r--r-- | Swiften/FileTransfer/FileWriteBytestream.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Swiften/FileTransfer/FileWriteBytestream.cpp b/Swiften/FileTransfer/FileWriteBytestream.cpp index 747e1de..bbf3d51 100644 --- a/Swiften/FileTransfer/FileWriteBytestream.cpp +++ b/Swiften/FileTransfer/FileWriteBytestream.cpp @@ -1,26 +1,28 @@ /* - * Copyright (c) 2010-2013 Isode Limited. + * Copyright (c) 2010-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ -#include <boost/filesystem/fstream.hpp> +#include <Swiften/FileTransfer/FileWriteBytestream.h> + #include <cassert> -#include <boost/numeric/conversion/cast.hpp> -#include <Swiften/FileTransfer/FileWriteBytestream.h> +#include <boost/filesystem/fstream.hpp> +#include <boost/numeric/conversion/cast.hpp> namespace Swift { FileWriteBytestream::FileWriteBytestream(const boost::filesystem::path& file) : file(file), stream(NULL) { } FileWriteBytestream::~FileWriteBytestream() { if (stream) { stream->close(); + delete stream; stream = NULL; } } void FileWriteBytestream::write(const std::vector<unsigned char>& data) { if (data.empty()) { @@ -34,11 +36,12 @@ void FileWriteBytestream::write(const std::vector<unsigned char>& data) { onWrite(data); } void FileWriteBytestream::close() { if (stream) { stream->close(); + delete stream; stream = NULL; } } } |