diff --git a/src/storage.cpp b/src/storage.cpp index 2bc368b6b..dbf6a9382 100755 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -403,16 +403,19 @@ namespace libtorrent assert(ph.offset == 0 || partial_copy.final() == partial.final()); #endif int slot_size = piece_size - ph.offset; - if (slot_size == 0) + if (slot_size > 0) { - assert(ph.h.final() == whole.final()); - return ph.h.final(); + m_scratch_buffer.resize(slot_size); + read_impl(&m_scratch_buffer[0], slot, ph.offset, slot_size, true); + ph.h.update(&m_scratch_buffer[0], slot_size); } - m_scratch_buffer.resize(slot_size); - read_impl(&m_scratch_buffer[0], slot, ph.offset, slot_size, true); - ph.h.update(&m_scratch_buffer[0], slot_size); - assert(whole.final() == ph.h.final()); +#ifndef NDEBUG + sha1_hash ret = ph.h.final(); + assert(ret == whole.final()); + return ret; +#else return ph.h.final(); +#endif } void storage::initialize(bool allocate_files)