Browse Source

Fix some invalid heap ops found by Dr Memory

Adam Johnson 11 years ago
parent
commit
8cedb69e9e
  1. 2
      Sources/Plasma/Apps/plClient/winmain.cpp
  2. 4
      Sources/Plasma/CoreLib/HeadSpin.cpp
  3. 2
      Sources/Plasma/PubUtilLib/plClientResMgr/plClientResMgr.cpp
  4. 2
      Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.cpp

2
Sources/Plasma/Apps/plClient/winmain.cpp

@ -896,7 +896,7 @@ static void LoadUserPass (LoginDialogParam *pLoginParam)
if (temp) if (temp)
{ {
StrCopy(pLoginParam->username, temp, kMaxAccountNameLength); StrCopy(pLoginParam->username, temp, kMaxAccountNameLength);
delete temp; delete[] temp;
} }
pLoginParam->remember = stream->ReadBool(); pLoginParam->remember = stream->ReadBool();

4
Sources/Plasma/CoreLib/HeadSpin.cpp

@ -366,8 +366,8 @@ char* hsStrcpy(char dst[], const char src[])
{ {
if (dst == nil) if (dst == nil)
{ {
int count = strlen(src); size_t count = strlen(src);
dst = (char *)malloc(count + 1); dst = new char[count + 1];
memcpy(dst, src, count); memcpy(dst, src, count);
dst[count] = 0; dst[count] = 0;
return dst; return dst;

2
Sources/Plasma/PubUtilLib/plClientResMgr/plClientResMgr.cpp

@ -101,7 +101,7 @@ void plClientResMgr::ILoadResources(const char* resfile)
char* tmp_name = in.ReadSafeStringLong(); char* tmp_name = in.ReadSafeStringLong();
std::string res_name = std::string(tmp_name); std::string res_name = std::string(tmp_name);
std::string res_type = res_name.substr(res_name.length() - 4, 4); std::string res_type = res_name.substr(res_name.length() - 4, 4);
delete tmp_name; delete[] tmp_name;
// Version 1 doesn't encode format, so we'll try some simple // Version 1 doesn't encode format, so we'll try some simple
// extension sniffing // extension sniffing

2
Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.cpp

@ -94,7 +94,7 @@ plProgressMgr::~plProgressMgr()
{ {
for (int i=0; i < LOADING_RES_COUNT; i++) for (int i=0; i < LOADING_RES_COUNT; i++)
{ {
delete fImageRotation[i]; delete[] fImageRotation[i];
} }
while( fOperations != nil ) while( fOperations != nil )

Loading…
Cancel
Save