summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-08-07 14:11:16 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-08-07 14:11:16 +0000
commitef5c01ad3373fa329d5aafbc49f9fd6dfb3e55ab (patch)
treea1e677ad4ff7854e29086003543ddda4bd19e81a
parent09417a063607b76c9deb54cfec4c7ea42e90aae8 (diff)
2008-08-07 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed unmatched malloc/free. * src/IteratableChunkChecksumValidator.cc * src/IteratableChecksumValidator.cc
-rw-r--r--ChangeLog6
-rw-r--r--src/IteratableChecksumValidator.cc10
-rw-r--r--src/IteratableChunkChecksumValidator.cc10
3 files changed, 22 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 44c4b4d8..b1db6c88 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2008-08-07 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
+ Fixed unmatched malloc/free.
+ * src/IteratableChunkChecksumValidator.cc
+ * src/IteratableChecksumValidator.cc
+
+2008-08-07 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
+
Removed max chunk size check. This change fixes BUG#2040169
* src/ChunkedDecoder.cc
* src/ChunkedDecoder.h
diff --git a/src/IteratableChecksumValidator.cc b/src/IteratableChecksumValidator.cc
index 42231c48..1d9283a9 100644
--- a/src/IteratableChecksumValidator.cc
+++ b/src/IteratableChecksumValidator.cc
@@ -59,7 +59,11 @@ IteratableChecksumValidator::IteratableChecksumValidator(const SingleFileDownloa
IteratableChecksumValidator::~IteratableChecksumValidator()
{
+#ifdef HAVE_POSIX_MEMALIGN
+ free(_buffer);
+#else // !HAVE_POSIX_MEMALIGN
delete [] _buffer;
+#endif // !HAVE_POSIX_MEMALIGN
}
void IteratableChecksumValidator::validateChunk()
@@ -100,10 +104,12 @@ uint64_t IteratableChecksumValidator::getTotalLength() const
void IteratableChecksumValidator::init()
{
#ifdef HAVE_POSIX_MEMALIGN
+ free(_buffer);
_buffer = (unsigned char*)Util::allocateAlignedMemory(ALIGNMENT, BUFSIZE);
-#else
+#else // !HAVE_POSIX_MEMALIGN
+ delete [] _buffer;
_buffer = new unsigned char[BUFSIZE];
-#endif // HAVE_POSIX_MEMALIGN
+#endif // !HAVE_POSIX_MEMALIGN
_pieceStorage->getDiskAdaptor()->enableDirectIO();
_currentOffset = 0;
_ctx.reset(new MessageDigestContext());
diff --git a/src/IteratableChunkChecksumValidator.cc b/src/IteratableChunkChecksumValidator.cc
index f901f0ee..00429479 100644
--- a/src/IteratableChunkChecksumValidator.cc
+++ b/src/IteratableChunkChecksumValidator.cc
@@ -66,7 +66,11 @@ IteratableChunkChecksumValidator(const DownloadContextHandle& dctx,
IteratableChunkChecksumValidator::~IteratableChunkChecksumValidator()
{
+#ifdef HAVE_POSIX_MEMALIGN
+ free(_buffer);
+#else // !HAVE_POSIX_MEMALIGN
delete [] _buffer;
+#endif // !HAVE_POSIX_MEMALIGN
}
@@ -115,10 +119,12 @@ std::string IteratableChunkChecksumValidator::calculateActualChecksum()
void IteratableChunkChecksumValidator::init()
{
#ifdef HAVE_POSIX_MEMALIGN
+ free(_buffer);
_buffer = (unsigned char*)Util::allocateAlignedMemory(ALIGNMENT, BUFSIZE);
-#else
+#else // !HAVE_POSIX_MEMALIGN
+ delete [] _buffer;
_buffer = new unsigned char[BUFSIZE];
-#endif // HAVE_POSIX_MEMALIGN
+#endif // !HAVE_POSIX_MEMALIGN
if(_dctx->getFileEntries().size() == 1) {
_pieceStorage->getDiskAdaptor()->enableDirectIO();
}