summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-07-16 07:45:52 (GMT)
committerTobias Markmann <tm@ayena.de>2015-07-16 07:45:52 (GMT)
commit382bce69ae2e94a2b9635a0be6db93a6ecd4ddce (patch)
treebab5e32775850da033313e74d7683da10c896d0b /Swiften
parent2c8a390256a9ef0c0d8c6c930594a68d8f6d2072 (diff)
downloadswift-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')
-rw-r--r--Swiften/FileTransfer/FileReadBytestream.cpp11
-rw-r--r--Swiften/FileTransfer/FileWriteBytestream.cpp11
2 files changed, 14 insertions, 8 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,15 +1,17 @@
/*
- * 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 {
@@ -20,6 +22,7 @@ FileReadBytestream::FileReadBytestream(const boost::filesystem::path& file) : fi
FileReadBytestream::~FileReadBytestream() {
if (stream) {
stream->close();
+ delete stream;
stream = NULL;
}
}
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,14 +1,15 @@
/*
- * 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 {
@@ -18,6 +19,7 @@ FileWriteBytestream::FileWriteBytestream(const boost::filesystem::path& file) :
FileWriteBytestream::~FileWriteBytestream() {
if (stream) {
stream->close();
+ delete stream;
stream = NULL;
}
}
@@ -37,6 +39,7 @@ void FileWriteBytestream::write(const std::vector<unsigned char>& data) {
void FileWriteBytestream::close() {
if (stream) {
stream->close();
+ delete stream;
stream = NULL;
}
}