fix double free in disk cache

This commit is contained in:
arvidn 2017-04-16 23:10:44 -04:00 committed by Arvid Norberg
parent f86e207ba2
commit 2d6268b580
2 changed files with 3 additions and 2 deletions

View File

@ -1,3 +1,4 @@
* fix double free in disk cache
* forward declaring libtorrent types is discouraged. a new fwd.hpp header is provided
1.1.3 release

View File

@ -757,13 +757,13 @@ namespace libtorrent
--pe->piece_refcount;
iovec_flushed(pe, flushing, iov_len, 0, error, completed_jobs);
m_disk_cache.maybe_free_piece(pe);
// if the cache is under high pressure, we need to evict
// the blocks we just flushed to make room for more write pieces
int evict = m_disk_cache.num_to_evict(0);
if (evict > 0) m_disk_cache.try_evict_blocks(evict);
m_disk_cache.maybe_free_piece(pe);
return iov_len;
}