From ef5c01ad3373fa329d5aafbc49f9fd6dfb3e55ab Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 7 Aug 2008 14:11:16 +0000 Subject: [PATCH] 2008-08-07 Tatsuhiro Tsujikawa Fixed unmatched malloc/free. * src/IteratableChunkChecksumValidator.cc * src/IteratableChecksumValidator.cc --- ChangeLog | 6 ++++++ src/IteratableChecksumValidator.cc | 10 ++++++++-- src/IteratableChunkChecksumValidator.cc | 10 ++++++++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 44c4b4d8d..b1db6c882 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-08-07 Tatsuhiro Tsujikawa + + Fixed unmatched malloc/free. + * src/IteratableChunkChecksumValidator.cc + * src/IteratableChecksumValidator.cc + 2008-08-07 Tatsuhiro Tsujikawa Removed max chunk size check. This change fixes BUG#2040169 diff --git a/src/IteratableChecksumValidator.cc b/src/IteratableChecksumValidator.cc index 42231c48f..1d9283a99 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 f901f0eeb..004294791 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(); }