free the allocated memory

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@4350 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2005-10-22 11:37:38 +00:00
parent f555ea4420
commit b33ce7e1df

View file

@ -143,15 +143,18 @@ void __declspec(dllexport) LangDialog(HWND hwndParent, int string_size,
// allocate language struct
langs = (struct lang *)GlobalAlloc(GPTR, langs_num*sizeof(struct lang));
if (!langs) return;
// fill language struct
for (i = 0; i < langs_num; i++) {
if (popstring(temp)) return;
langs[i].name = GlobalAlloc(GPTR, lstrlen(temp)+1);
if (!langs[i].name) return;
lstrcpy(langs[i].name, temp);
if (popstring(temp)) return;
langs[i].id = GlobalAlloc(GPTR, lstrlen(temp)+1);
if (!langs[i].id) return;
lstrcpy(langs[i].id, temp);
}
@ -160,7 +163,15 @@ void __declspec(dllexport) LangDialog(HWND hwndParent, int string_size,
if (popstring(temp)) return;
}
// start dialog
DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG), 0, DialogProc);
// free structs
for (i = 0; i < langs_num; i++) {
GlobalFree(langs[i].name);
GlobalFree(langs[i].id);
}
GlobalFree(langs);
}
}