From 3ea52b240f2e46d95baad85a4e828b29a74bec36 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Thu, 28 May 2009 01:19:48 +0000 Subject: [PATCH] fixed memory leak in disk cache --- ChangeLog | 1 + src/disk_io_thread.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9754077ab..a3d410964 100644 --- a/ChangeLog +++ b/ChangeLog @@ -70,6 +70,7 @@ release 0.14.4 * fixed bug when checking a torrent twice * improved handling of out-of-memory conditions in disk I/O thread * fixed bug when force-checking a torrent with partial pieces + * fixed memory leak in disk cache release 0.14.3 diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index 0f8c362c0..d3b61e416 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -897,7 +897,7 @@ namespace libtorrent std::memset(&p.blocks[0], 0, blocks_in_piece * sizeof(char*)); int ret = read_into_piece(p, 0, ignore_cache_size, INT_MAX, l); - if (ret == -1) + if (ret < 0) free_piece(p, l); else m_read_pieces.push_back(p); @@ -936,7 +936,7 @@ namespace libtorrent std::memset(&p.blocks[0], 0, blocks_in_piece * sizeof(char*)); int ret = read_into_piece(p, start_block, 0, blocks_to_read, l); - if (ret == -1) + if (ret < 0) free_piece(p, l); else m_read_pieces.push_back(p); @@ -1421,6 +1421,9 @@ namespace libtorrent // reading and hashing, not for keeping it around) sha1_hash h; ret = read_piece_from_cache_and_hash(j, h); + + // -2 means there's no space in the read cache + // or that the read cache is disabled if (ret == -1) { test_error(j);