From b33ce7e1dfd2afea51ba689fa18a1cac75cb83a1 Mon Sep 17 00:00:00 2001 From: kichik Date: Sat, 22 Oct 2005 11:37:38 +0000 Subject: [PATCH] free the allocated memory git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@4350 212acab6-be3b-0410-9dea-997c60f758d6 --- Contrib/LangDLL/LangDLL.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Contrib/LangDLL/LangDLL.c b/Contrib/LangDLL/LangDLL.c index b59286e9..fa4a7a8e 100644 --- a/Contrib/LangDLL/LangDLL.c +++ b/Contrib/LangDLL/LangDLL.c @@ -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); } }