From 5df55a4f1f2042608ca3da075083ae8d26005361 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 6 Apr 2014 07:37:24 +0000 Subject: [PATCH] avoid potential memory leak for cache files that have been downloaded multiple times. Not sure that this is the cause anyway. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5.5@7242 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/ft/ftcontroller.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libretroshare/src/ft/ftcontroller.cc b/libretroshare/src/ft/ftcontroller.cc index 59453257d..5f3769e05 100644 --- a/libretroshare/src/ft/ftcontroller.cc +++ b/libretroshare/src/ft/ftcontroller.cc @@ -890,7 +890,16 @@ bool ftController::completeFile(std::string hash) /* switch map */ if (!(fc->mFlags & RS_FILE_REQ_CACHE)) /* clean up completed cache files automatically */ { - mCompleted[fc->mHash] = fc; + std::map::iterator it = mCompleted.find(fc->mHash) ; + + if(it != mCompleted.end()) + { + delete it->second ; + it->second = fc ; + } + else + mCompleted[fc->mHash] = fc; + completeCount = mCompleted.size(); } else delete fc ;