Fix some memory leaks

import/tags/kmeleon75_1
boisso 7 years ago
parent e249362e69
commit a3d8e68d57
  1. 12
      k-meleon/macros2/functions.h
  2. 3
      k-meleon/sessions/sessions.h
  3. 8
      k-meleon/sessions/sessionstore.cpp

@ -380,15 +380,15 @@
if (preftype == PREF_UNISTRING) {
long len = kFuncs->GetPreference(PREF_STRING, pref, 0, L"");
if (!len) return Value("");
char* cRetval = (char*)calloc(sizeof(char), len+1);
kFuncs->GetPreference(PREF_STRING, pref, cRetval, L"");
if (strncmp(cRetval, "chrome:",7) == 0) {
std::auto_ptr<char> cRetval((char*)calloc(sizeof(char), len+1));
kFuncs->GetPreference(PREF_STRING, pref, cRetval.get(), L"");
if (strncmp(cRetval.get(), "chrome:",7) == 0) {
len = kFuncs->GetPreference(PREF_LOCALIZED, pref, 0, L"");
if (!len) return Value("");
cRetval = (char*)calloc(sizeof(char), len+1);
kFuncs->GetPreference(PREF_LOCALIZED, pref, cRetval, L"");
cRetval.reset((char*)calloc(sizeof(char), len+1));
kFuncs->GetPreference(PREF_LOCALIZED, pref, cRetval.get(), L"");
}
Value v(cRetval);
Value v(cRetval.get());
return v;
}
else if (preftype == PREF_INT) {

@ -100,9 +100,10 @@ public:
aUrls[i] = urls[i].c_str();
aTitles[i] = titles[i].c_str();
}
kPlugin.kFuncs->SetMozillaSessionHistory(hWnd, aTitles, aUrls, shcount, index, scrollX, scrollY);
if (last) kPlugin.kFuncs->GotoHistoryIndex(hWnd, index);
delete aTitles;
delete aUrls;
return false;
}

@ -276,11 +276,11 @@ bool SessionStore::Load()
if (_tstat(sessionFile, &st) == -1)
return false;
char* input = new char[st.st_size+1];
f.read(input, st.st_size);
input[f.gcount()] = 0;
std::auto_ptr<char> input(new char[st.st_size+1]);
f.read(input.get(), st.st_size);
input.get()[f.gcount()] = 0;
data.Parse(input);
data.Parse(input.get());
if (data.HasParseError() || !data["sessions"].IsArray())
InitData();
UpdateSessionList();

Loading…
Cancel
Save