From 5d6a4181191ec5eb92f2596fe6099f4009ec12ff Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Sun, 29 Jul 2012 22:17:00 +0300 Subject: fixed memorry corruption's improoved autoexchange --- src/main.cpp | 80 ++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 34 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 3857f38..0c212d4 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -1218,16 +1218,17 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam, { wstring path; { //data sanity checks - TCHAR *tmp = new TCHAR [5]; + TCHAR *tmp = (TCHAR*)mir_alloc(sizeof(TCHAR)*5); GetDlgItemText(hwndDlg, IDC_KEY_TYPE, tmp, 5); if(_tcslen(tmp) < 3) { - mir_free(tmp); + mir_free(tmp); tmp = NULL; MessageBox(0, TranslateT("You must set encryption algorythm first"), TranslateT("Error"), MB_OK); break; } - mir_free(tmp); - tmp = new TCHAR [5]; + if(tmp) + mir_free(tmp); + tmp = (TCHAR*)mir_alloc(sizeof(TCHAR)*6); GetDlgItemText(hwndDlg, IDC_KEY_LENGTH, tmp, 5); int length = _ttoi(tmp); mir_free(tmp); @@ -1236,39 +1237,39 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam, MessageBox(0, TranslateT("Key length must be of length from 1024 to 4096 bits"), TranslateT("Error"), MB_OK); break; } - tmp = new TCHAR [12]; - GetDlgItemText(hwndDlg, IDC_KEY_EXPIRE_DATE, tmp, 12); + tmp = (TCHAR*)mir_alloc(sizeof(TCHAR)*12); + GetDlgItemText(hwndDlg, IDC_KEY_EXPIRE_DATE, tmp, 11); if(_tcslen(tmp) != 10 && tmp[0] != '0') { MessageBox(0, TranslateT("Invalid date"), TranslateT("Error"), MB_OK); - delete [] tmp; + mir_free(tmp); break; } - delete [] tmp; - tmp = new TCHAR [128]; - GetDlgItemText(hwndDlg, IDC_KEY_REAL_NAME, tmp, 128); + mir_free(tmp); + tmp = (TCHAR*)mir_alloc(sizeof(TCHAR)*128); + GetDlgItemText(hwndDlg, IDC_KEY_REAL_NAME, tmp, 127); if(_tcslen(tmp) < 5) { MessageBox(0, TranslateT("Name must contain at least 5 characters"), TranslateT("Error"), MB_OK); - delete [] tmp; + mir_free(tmp); break; } else if (_tcschr(tmp, _T('(')) || _tcschr(tmp, _T(')'))) { MessageBox(0, TranslateT("Name cannot contain '(' or ')'"), TranslateT("Error"), MB_OK); - delete [] tmp; + mir_free(tmp); break; } - delete [] tmp; - tmp = new TCHAR [128]; + mir_free(tmp); + tmp = (TCHAR*)mir_alloc(sizeof(TCHAR)*128); GetDlgItemText(hwndDlg, IDC_KEY_EMAIL, tmp, 128); if((_tcslen(tmp)) < 5 || (!_tcschr(tmp, _T('@'))) || (!_tcschr(tmp, _T('.')))) { MessageBox(0, TranslateT("Invalid Email"), TranslateT("Error"), MB_OK); - delete [] tmp; + mir_free(tmp); break; } - delete [] tmp; + mir_free(tmp); } { //generating key file TCHAR *tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", _T("")); @@ -1284,11 +1285,11 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam, break; } f<<"Key-Type: "; - tmp = new TCHAR [5]; + tmp = (TCHAR*)mir_alloc(sizeof(TCHAR)*5); GetDlgItemText(hwndDlg, IDC_KEY_TYPE, tmp, 5); tmp2 = mir_t2a(tmp); - delete [] tmp; - char *subkeytype = new char [6]; + mir_free(tmp); + char *subkeytype = (char*)mir_alloc(6); if(strstr(tmp2, "RSA")) strcpy(subkeytype, "RSA"); else if(strstr(tmp2, "DSA")) //this is useless check for now, but it will be required if someone add another key types support @@ -1297,10 +1298,10 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam, mir_free(tmp2); f<<"\n"; f<<"Key-Length: "; - tmp = new TCHAR [5]; + tmp = (TCHAR*)mir_alloc(sizeof(TCHAR)*5); GetDlgItemText(hwndDlg, IDC_KEY_LENGTH, tmp, 5); int length = _ttoi(tmp); - delete [] tmp; + mir_free(tmp); f<szProtoName); + strcat(svc, PS_ICQ_ADDCAPABILITY); + if(ServiceExists(svc)) + CallService(svc, 0, (LPARAM)&cap); + } } } -- cgit v1.2.3