From 16b1dd7eb165fcf66b14798b0892b8c3b55c83a7 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Mon, 13 Sep 2010 20:28:21 +0000 Subject: [PATCH] Remove memory leak in p3ChatService::receiveAvatarJpegData, when a peer changed the avatar. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3481 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/services/p3chatservice.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libretroshare/src/services/p3chatservice.cc b/libretroshare/src/services/p3chatservice.cc index 04b11ad1c..30929bcb6 100644 --- a/libretroshare/src/services/p3chatservice.cc +++ b/libretroshare/src/services/p3chatservice.cc @@ -619,6 +619,7 @@ void p3ChatService::receiveStateString(const std::string& id,const std::string& _state_strings[id]._peer_is_new = true ; _state_strings[id]._own_is_new = new_peer ; } + void p3ChatService::receiveAvatarJpegData(RsChatAvatarItem *ci) { RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/ @@ -628,6 +629,9 @@ void p3ChatService::receiveAvatarJpegData(RsChatAvatarItem *ci) bool new_peer = (_avatars.find(ci->PeerId()) == _avatars.end()) ; + if (new_peer == false && _avatars[ci->PeerId()]) { + delete _avatars[ci->PeerId()]; + } _avatars[ci->PeerId()] = new AvatarInfo(ci->image_data,ci->image_size) ; _avatars[ci->PeerId()]->_peer_is_new = true ; _avatars[ci->PeerId()]->_own_is_new = new_peer ;