From 7e61d4900d9b99958f863cd2f56fc3cd4e800600 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 8 Jun 2012 21:56:45 +0000 Subject: memory crash fixes git-svn-id: http://svn.miranda-ng.org/main/trunk@367 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TopToolBar/ttbopt.cpp | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'plugins/TopToolBar/ttbopt.cpp') diff --git a/plugins/TopToolBar/ttbopt.cpp b/plugins/TopToolBar/ttbopt.cpp index 6167f3e19e..fddfbe5e84 100644 --- a/plugins/TopToolBar/ttbopt.cpp +++ b/plugins/TopToolBar/ttbopt.cpp @@ -84,26 +84,30 @@ void AssignBitmapsFromDir(TCHAR *dir) wsprintf(curnameDN, _T("%s%s_DN.bmp"), dir, ChangedName); if ( FileExists(curnameUP)) { - if (Buttons[i].UserDefinedbmUp != NULL){free(Buttons[i].UserDefinedbmUp);} - Buttons[i].UserDefinedbmUp = _tcsdup(curnameUP); + if (Buttons[i].UserDefinedbmUp != NULL) + mir_free(Buttons[i].UserDefinedbmUp); + Buttons[i].UserDefinedbmUp = mir_tstrdup(curnameUP); } if ( FileExists(curnameDN)) { - if (Buttons[i].UserDefinedbmDown != NULL){free(Buttons[i].UserDefinedbmDown);} - Buttons[i].UserDefinedbmDown = _tcsdup(curnameDN); + if (Buttons[i].UserDefinedbmDown != NULL) + mir_free(Buttons[i].UserDefinedbmDown); + Buttons[i].UserDefinedbmDown = mir_tstrdup(curnameDN); } wsprintf(curnameUP, _T("%s%s_UP.ico"), dir, ChangedName); wsprintf(curnameDN, _T("%s%s_DN.ico"), dir, ChangedName); if ( FileExists(curnameUP)) { - if (Buttons[i].UserDefinedbmUp != NULL){free(Buttons[i].UserDefinedbmUp);} - Buttons[i].UserDefinedbmUp = _tcsdup(curnameUP); + if (Buttons[i].UserDefinedbmUp != NULL) + mir_free(Buttons[i].UserDefinedbmUp); + Buttons[i].UserDefinedbmUp = mir_tstrdup(curnameUP); } if ( FileExists(curnameDN)) { - if (Buttons[i].UserDefinedbmDown != NULL){free(Buttons[i].UserDefinedbmDown);} - Buttons[i].UserDefinedbmDown = _tcsdup(curnameDN); + if (Buttons[i].UserDefinedbmDown != NULL) + mir_free(Buttons[i].UserDefinedbmDown); + Buttons[i].UserDefinedbmDown = mir_tstrdup(curnameDN); } } @@ -418,8 +422,8 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR int curselect = ((ButtonOptData *)tvi.lParam)->pos; lockbut(); - if (Buttons[curselect].UserDefinedbmUp != NULL) free(Buttons[curselect].UserDefinedbmUp); - if (Buttons[curselect].UserDefinedbmDown != NULL) free(Buttons[curselect].UserDefinedbmDown); + if (Buttons[curselect].UserDefinedbmUp != NULL) mir_free(Buttons[curselect].UserDefinedbmUp); + if (Buttons[curselect].UserDefinedbmDown != NULL) mir_free(Buttons[curselect].UserDefinedbmDown); Buttons[curselect].UserDefinedbmUp = NULL; Buttons[curselect].UserDefinedbmDown = NULL; applyuserbitmaps(curselect); @@ -476,12 +480,14 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if (GetOpenFileName(&ofn)) { lockbut(); if (ctrlid == IDC_BMPUP){ - if (Buttons[curselect].UserDefinedbmUp != NULL){free(Buttons[curselect].UserDefinedbmUp);} - Buttons[curselect].UserDefinedbmUp = _tcsdup(ofn.lpstrFile); + if (Buttons[curselect].UserDefinedbmUp != NULL) + mir_free(Buttons[curselect].UserDefinedbmUp); + Buttons[curselect].UserDefinedbmUp = mir_tstrdup(ofn.lpstrFile); } if (ctrlid == IDC_BMPDN){ - if (Buttons[curselect].UserDefinedbmDown != NULL){free(Buttons[curselect].UserDefinedbmDown);} - Buttons[curselect].UserDefinedbmDown = _tcsdup(ofn.lpstrFile); + if (Buttons[curselect].UserDefinedbmDown != NULL) + mir_free(Buttons[curselect].UserDefinedbmDown); + Buttons[curselect].UserDefinedbmDown = mir_tstrdup(ofn.lpstrFile); } applyuserbitmaps(curselect); SetImagesForCurrent(hwndDlg, curselect); -- cgit v1.2.3