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/FileReadBytestream.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/FileReadBytestream.cpp')
-rw-r--r-- | Swiften/FileTransfer/FileReadBytestream.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Swiften/FileTransfer/FileReadBytestream.cpp b/Swiften/FileTransfer/FileReadBytestream.cpp index 5885076..4700a9c 100644 --- a/Swiften/FileTransfer/FileReadBytestream.cpp +++ b/Swiften/FileTransfer/FileReadBytestream.cpp @@ -1,28 +1,31 @@ /* - * 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/FileReadBytestream.h> + #include <cassert> -#include <boost/smart_ptr/make_shared.hpp> + +#include <boost/filesystem/fstream.hpp> #include <boost/numeric/conversion/cast.hpp> +#include <boost/smart_ptr/make_shared.hpp> -#include <Swiften/FileTransfer/FileReadBytestream.h> #include <Swiften/Base/ByteArray.h> namespace Swift { FileReadBytestream::FileReadBytestream(const boost::filesystem::path& file) : file(file), stream(NULL) { } FileReadBytestream::~FileReadBytestream() { if (stream) { stream->close(); + delete stream; stream = NULL; } } boost::shared_ptr<ByteArray> FileReadBytestream::read(size_t size) { if (!stream) { |