diff --git a/include/libtorrent/bitfield.hpp b/include/libtorrent/bitfield.hpp index bd53086bb..f970c7257 100644 --- a/include/libtorrent/bitfield.hpp +++ b/include/libtorrent/bitfield.hpp @@ -222,6 +222,7 @@ namespace libtorrent void resize(int bits) { + TORRENT_ASSERT(bits >= 0); const int b = (bits + 7) / 8; if (m_bytes) { @@ -238,7 +239,7 @@ namespace libtorrent m_own = true; } } - else + else if (bits > 0) { m_bytes = (unsigned char*)std::malloc(b); m_own = true;