Browse Source

Merge pull request #388 from Hoikas/leaks

Fix some leaks revealed by Coverity
Adam Johnson 11 years ago
parent
commit
fc06d95858
  1. 16
      Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerNode.cpp
  2. 12
      Sources/Plasma/PubUtilLib/plClipboard/plClipboard.cpp
  3. 11
      Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp

16
Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerNode.cpp

@ -183,27 +183,23 @@ PyObject *pyVaultPlayerNode::GetPlayerInfo()
PyObject *pyVaultPlayerNode::GetLinkToMyNeighborhood()
{
plAgeLinkStruct * link = new plAgeLinkStruct();
if (VaultGetLinkToMyNeighborhood(link)) {
PyObject * result = pyAgeLinkStruct::New(link);
plAgeLinkStruct link;
if (VaultGetLinkToMyNeighborhood(&link)) {
PyObject * result = pyAgeLinkStruct::New(&link);
return result;
}
delete link;
PYTHON_RETURN_NONE;
}
PyObject *pyVaultPlayerNode::GetLinkToCity()
{
plAgeLinkStruct * link = new plAgeLinkStruct();
if (VaultGetLinkToCity(link)) {
PyObject * result = pyAgeLinkStruct::New(link);
plAgeLinkStruct link;
if (VaultGetLinkToCity(&link)) {
PyObject * result = pyAgeLinkStruct::New(&link);
return result;
}
delete link;
PYTHON_RETURN_NONE;
}

12
Sources/Plasma/PubUtilLib/plClipboard/plClipboard.cpp

@ -43,6 +43,8 @@ Mead, WA 99021
#include "plClipboard.h"
#include "hsWindows.h"
#include <memory>
plClipboard& plClipboard::GetInstance()
{
static plClipboard theInstance;
@ -93,8 +95,8 @@ void plClipboard::SetClipboardText(const plString& text)
if (len == 0)
return;
HGLOBAL copy = ::GlobalAlloc(GMEM_MOVEABLE, (len + 1) * sizeof(wchar_t));
if (copy == NULL)
std::unique_ptr<void, HGLOBAL(WINAPI*)(HGLOBAL)> copy(::GlobalAlloc(GMEM_MOVEABLE, (len + 1) * sizeof(wchar_t)), ::GlobalFree);
if (!copy)
return;
if (!::OpenClipboard(NULL))
@ -102,12 +104,12 @@ void plClipboard::SetClipboardText(const plString& text)
::EmptyClipboard();
wchar_t* target = (wchar_t*)::GlobalLock(copy);
wchar_t* target = (wchar_t*)::GlobalLock(copy.get());
memcpy(target, buf.GetData(), (len + 1) * sizeof(wchar_t));
target[len] = '\0';
::GlobalUnlock(copy);
::GlobalUnlock(copy.get());
::SetClipboardData(CF_UNICODETEXT, copy);
::SetClipboardData(CF_UNICODETEXT, copy.get());
::CloseClipboard();
#endif
}

11
Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp

@ -740,19 +740,18 @@ void plNetLinkingMgr::OfferLinkToPlayer( const plAgeLinkStruct * inInfo, uint32_
// my special version - cjp
void plNetLinkingMgr::OfferLinkToPlayer( const plAgeLinkStruct * inInfo, uint32_t playerID, plKey replyKey )
{
plNetClientMgr *mgr = plNetClientMgr::GetInstance();
plLinkToAgeMsg * linkM = new plLinkToAgeMsg(inInfo);
linkM->AddReceiver(mgr->GetKey());
plKey host = mgr->GetLocalPlayerKey();
plNetTransport &transport = mgr->TransportMgr();
int guestIdx = transport.FindMember(playerID);
plNetTransportMember *guestMem = transport.GetMember(guestIdx); // -1 ?
if(guestMem)
if (guestMem)
{
plLinkToAgeMsg* linkM = new plLinkToAgeMsg(inInfo);
linkM->AddReceiver(mgr->GetKey());
plKey guest = guestMem->GetAvatarKey();
plKey host = mgr->GetLocalPlayerKey();
plAvatarMgr::OfferLinkingBook(host, guest, linkM, replyKey);
}
}

Loading…
Cancel
Save