diff options
-rwxr-xr-x | src/gpg_wrapper.cpp | 4 | ||||
-rwxr-xr-x | src/init.cpp | 2 | ||||
-rwxr-xr-x | src/main.cpp | 80 | ||||
-rwxr-xr-x | src/messages.cpp | 91 | ||||
-rwxr-xr-x | src/options.cpp | 21 | ||||
-rwxr-xr-x | src/utilities.cpp | 25 |
6 files changed, 126 insertions, 97 deletions
diff --git a/src/gpg_wrapper.cpp b/src/gpg_wrapper.cpp index 410a0d5..38f8688 100755 --- a/src/gpg_wrapper.cpp +++ b/src/gpg_wrapper.cpp @@ -96,8 +96,8 @@ pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD commandline += _T("--display-charset utf-8 "); commandline += _T("-z 9 "); commandline += *acommandline; - delete [] bin_path; //hmm - delete [] home_dir; + mir_free(bin_path); + mir_free(home_dir); } debuglog<<time_str()<<": gpg in: "<<commandline<<"\n"; diff --git a/src/init.cpp b/src/init.cpp index b87e76f..90030b0 100755 --- a/src/init.cpp +++ b/src/init.cpp @@ -283,6 +283,6 @@ extern "C" int __declspec(dllexport) Unload(void) mir_free(outopentag);
mir_free(outclosetag);
if(password)
- delete [] password;
+ mir_free(password);
return 0;
}
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<<length; f<<"\n"; f<<"Subkey-Length: "; @@ -1308,9 +1309,9 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam, f<<"\n"; f<<"Subkey-Type: "; f<<subkeytype; - delete [] subkeytype; + mir_free(subkeytype); f<<"\n"; - tmp = new TCHAR [64]; //i hope this is enough for password + tmp = (TCHAR*)mir_alloc(sizeof(TCHAR)*64); //i hope this is enough for password GetDlgItemText(hwndDlg, IDC_KEY_PASSWD, tmp, 64); if(tmp[0]) { @@ -1320,16 +1321,16 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam, f<<"\n"; mir_free(tmp2); } - delete [] tmp; + mir_free(tmp); f<<"Name-Real: "; - tmp = new TCHAR [128]; + tmp = (TCHAR*)mir_alloc(sizeof(TCHAR)*128); GetDlgItemText(hwndDlg, IDC_KEY_REAL_NAME, tmp, 128); tmp2 = mir_strdup(toUTF8(tmp).c_str()); f<<tmp2; mir_free(tmp2); - delete [] tmp; + mir_free(tmp); f<<"\n"; - tmp = new TCHAR [512]; + tmp = (TCHAR*)mir_alloc(sizeof(TCHAR)*512); GetDlgItemText(hwndDlg, IDC_KEY_COMMENT, tmp, 512); if(tmp[0]) { @@ -1339,22 +1340,22 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam, f<<"\n"; } mir_free(tmp2); - delete [] tmp; + mir_free(tmp); f<<"Name-Email: "; - tmp = new TCHAR [128]; + tmp = (TCHAR*)mir_alloc(sizeof(TCHAR)*128); GetDlgItemText(hwndDlg, IDC_KEY_EMAIL, tmp, 128); tmp2 = mir_strdup(toUTF8(tmp).c_str()); f<<tmp2; mir_free(tmp2); - delete [] tmp; + mir_free(tmp); f<<"\n"; f<<"Expire-Date: "; - tmp = new TCHAR [12]; + tmp = (TCHAR*)mir_alloc(sizeof(TCHAR)*12); GetDlgItemText(hwndDlg, IDC_KEY_EXPIRE_DATE, tmp, 12); tmp2 = mir_strdup(toUTF8(tmp).c_str()); f<<tmp2; mir_free(tmp2); - delete [] tmp; + mir_free(tmp); f<<"\n"; f.close(); } @@ -2023,14 +2024,25 @@ void InitCheck() mir_free(path); } extern bool bAutoExchange; - if(bAutoExchange && (ServiceExists("ICQ"PS_ICQ_ADDCAPABILITY))) //work only for one icq instance + if(bAutoExchange) { + int count = 0; + PROTOACCOUNT **accounts; + ProtoEnumAccounts(&count, &accounts); ICQ_CUSTOMCAP cap; cap.cbSize = sizeof(ICQ_CUSTOMCAP); cap.hIcon = 0; strcpy(cap.name, "GPG Key AutoExchange"); strcpy(cap.caps, "GPG AutoExchange"); - CallService("ICQ"PS_ICQ_ADDCAPABILITY, 0, (LPARAM)&cap); + + for(int i = 0; i < count; i++) + { + char svc[64]; + strcpy(svc, accounts[i]->szProtoName); + strcat(svc, PS_ICQ_ADDCAPABILITY); + if(ServiceExists(svc)) + CallService(svc, 0, (LPARAM)&cap); + } } } diff --git a/src/messages.cpp b/src/messages.cpp index f2e3c35..ba9a36c 100755 --- a/src/messages.cpp +++ b/src/messages.cpp @@ -456,7 +456,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l) s2 = output.find("<", s); else if(s2 > output.find("<", s)) s2 = output.find("<", s); - tmp = new char [output.substr(s,s2-s-1).length()+1]; + tmp = (char*)mir_alloc(output.substr(s,s2-s-1).length()+1); strcpy(tmp, output.substr(s,s2-s-1).c_str()); mir_utf8decode(tmp, 0); DBWriteContactSettingString(ccs->hContact, szGPGModuleName, "KeyMainName", tmp); @@ -468,14 +468,14 @@ int RecvMsgSvc(WPARAM w, LPARAM l) s2++; if(output[s] == ')') { - tmp = new char [output.substr(s2,s-s2).length()+1]; + tmp = (char*)mir_alloc(output.substr(s2,s-s2).length()+1); strcpy(tmp, output.substr(s2,s-s2).c_str()); mir_utf8decode(tmp, 0); DBWriteContactSettingString(ccs->hContact, szGPGModuleName, "KeyComment", tmp); mir_free(tmp); s+=3; s2 = output.find(">", s); - tmp = new char [output.substr(s,s2-s).length()+1]; + tmp = (char*)mir_alloc(output.substr(s,s2-s).length()+1); strcpy(tmp, output.substr(s,s2-s).c_str()); mir_utf8decode(tmp, 0); DBWriteContactSettingString(ccs->hContact, szGPGModuleName, "KeyMainEmail", tmp); @@ -483,7 +483,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l) } else { - tmp = new char [output.substr(s2,s-s2).length()+1]; + tmp = (char*)mir_alloc(output.substr(s2,s-s2).length()+1); strcpy(tmp, output.substr(s2,s-s2).c_str()); mir_utf8decode(tmp, 0); DBWriteContactSettingString(ccs->hContact, szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str()); @@ -561,54 +561,64 @@ int RecvMsgSvc(WPARAM w, LPARAM l) DBWriteContactSettingByte(ccs->hContact, szGPGModuleName, "GPGEncryption", 1); } mir_free(tmp); - if(!isContactHaveKey(ccs->hContact) && bAutoExchange && gpg_valid && gpg_keyexist) + return returnNoError(ccs->hContact); + } + else if(!isContactHaveKey(ccs->hContact) && bAutoExchange && gpg_valid && gpg_keyexist) + { + LPSTR proto = (LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ccs->hContact, 0); + DWORD uin = DBGetContactSettingDword(ccs->hContact, proto, "UIN", 0); + if(uin) { - LPSTR proto = (LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ccs->hContact, 0); - DWORD uin = DBGetContactSettingDword(ccs->hContact, proto, "UIN", 0); - if(uin) + char *proto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ccs->hContact, 0); + char svc[64]; + strcpy(svc, proto); + strcat(svc, PS_ICQ_CHECKCAPABILITY); + if(ServiceExists(svc)) { - if(ServiceExists("ICQ"PS_ICQ_CHECKCAPABILITY)) + ICQ_CUSTOMCAP cap = {0}; + strcpy(cap.caps, "GPG AutoExchange"); + if(CallService(svc, (WPARAM)ccs->hContact, (LPARAM)&cap)) { - ICQ_CUSTOMCAP cap = {0}; - strcpy(cap.caps, "GPG AutoExchange"); - if(CallService("ICQ"PS_ICQ_CHECKCAPABILITY, (WPARAM)ccs->hContact, (LPARAM)&cap)) - CallContactService(ccs->hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)"-----PGP KEY REQUEST-----"); + CallContactService(ccs->hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)"-----PGP KEY REQUEST-----"); + return returnNoError(ccs->hContact); } } - else + } + else + { + TCHAR *jid = UniGetContactSettingUtf(ccs->hContact, proto, "jid", _T("")); + if(jid[0]) { - TCHAR *jid = UniGetContactSettingUtf(ccs->hContact, proto, "jid", _T("")); - if(jid[0]) + extern list <JabberAccount*> Accounts; + list<JabberAccount*>::iterator end = Accounts.end(); + for(list<JabberAccount*>::iterator p = Accounts.begin(); p != end; p++) { - extern list <JabberAccount*> Accounts; - list<JabberAccount*>::iterator end = Accounts.end(); - for(list<JabberAccount*>::iterator p = Accounts.begin(); p != end; p++) + TCHAR *caps = (*p)->getJabberInterface()->Net()->GetResourceFeatures(jid); + if(caps) { - TCHAR *caps = (*p)->getJabberInterface()->Net()->GetResourceFeatures(jid); - if(caps) + wstring str; + for(int i =0;;i++) + { + str.push_back(caps[i]); + if(caps[i] == '\0') + if(caps[i+1] == '\0') + break; + } + mir_free(caps); + if(str.find(_T("GPG_Key_Auto_Exchange:0")) != string::npos) { - wstring str; - for(int i =0;;i++) - { - str.push_back(caps[i]); - if(caps[i] == '\0') - if(caps[i+1] == '\0') - break; - } - mir_free(caps); - if(str.find(_T("GPG_Key_Auto_Exchange:0")) != string::npos) - CallContactService(ccs->hContact, PSS_MESSAGE, (WPARAM)0, (LPARAM)"-----PGP KEY REQUEST-----"); + CallContactService(ccs->hContact, PSS_MESSAGE, (WPARAM)0, (LPARAM)"-----PGP KEY REQUEST-----"); + return returnNoError(ccs->hContact); } } } } } - return 1; } if(!(strstr(msg, "-----BEGIN PGP MESSAGE-----") && strstr(msg, "-----END PGP MESSAGE-----"))) return CallService(MS_PROTO_CHAINRECV, w, l); - boost::thread *thr = new boost::thread(boost::bind(RecvMsgSvc_func, ccs->hContact, str, msg, ccs->wParam, pre->timestamp)); - return returnNoError(ccs->hContact); + boost::thread *thr = new boost::thread(boost::bind(RecvMsgSvc_func, ccs->hContact, str, msg, ccs->wParam, pre->timestamp)); + return returnNoError(ccs->hContact); } int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) @@ -827,11 +837,16 @@ int SendMsgSvc(WPARAM w, LPARAM l) DWORD uin = DBGetContactSettingDword(ccs->hContact, proto, "UIN", 0); if(uin) { - if(ServiceExists("ICQ"PS_ICQ_CHECKCAPABILITY)) + char *proto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ccs->hContact, 0); + char svc[64]; + strcpy(svc, proto); + strcat(svc, PS_ICQ_CHECKCAPABILITY); + + if(ServiceExists(svc)) { ICQ_CUSTOMCAP cap = {0}; strcpy(cap.caps, "GPG AutoExchange"); - if(CallService("ICQ"PS_ICQ_CHECKCAPABILITY, (WPARAM)ccs->hContact, (LPARAM)&cap)) + if(CallService(svc, (WPARAM)ccs->hContact, (LPARAM)&cap)) { CallContactService(ccs->hContact, PSS_MESSAGE, (WPARAM)ccs->wParam, (LPARAM)"-----PGP KEY REQUEST-----"); hcontact_data[ccs->hContact].msgs_to_send.push_back(msg); @@ -854,7 +869,7 @@ int SendMsgSvc(WPARAM w, LPARAM l) if(caps) { wstring str; - for(int i =0;;i++) + for(int i=0;;i++) { str.push_back(caps[i]); if(caps[i] == '\0') diff --git a/src/options.cpp b/src/options.cpp index a990003..f03879c 100755 --- a/src/options.cpp +++ b/src/options.cpp @@ -796,7 +796,7 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP {
tmp = UniGetContactSettingUtf(hcnt, szGPGModuleName, "GPGPubKey", _T(""));
wstring str = tmp;
- mir_free(tmp);
+ mir_free(tmp); tmp = NULL;
wstring::size_type p = 0, stop = 0;
if(!str.empty())
{
@@ -878,7 +878,8 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP }
mir_free(tmp2);
}
- mir_free(tmp);
+ if(tmp)
+ mir_free(tmp);
SetDlgItemText(hwndDlg, IDC_PUBLIC_KEY_EDIT, !str.empty()?str.c_str():_T(""));
}
hPubKeyEdit = GetDlgItem(hwndDlg, IDC_PUBLIC_KEY_EDIT);
@@ -904,16 +905,16 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP ws1 = 0;
if(((ws2 = key_buf.find(_T("-----END PGP PUBLIC KEY BLOCK-----"))) != wstring::npos) && ((ws1 = key_buf.find(_T("-----BEGIN PGP PUBLIC KEY BLOCK-----"))) != wstring::npos))
{
- begin = new TCHAR [_tcslen(_T("-----BEGIN PGP PUBLIC KEY BLOCK-----")) + 1];
+ begin = (TCHAR*)mir_alloc(sizeof(TCHAR) * (_tcslen(_T("-----BEGIN PGP PUBLIC KEY BLOCK-----")) + 1));
_tcscpy(begin, _T("-----BEGIN PGP PUBLIC KEY BLOCK-----"));
- end = new TCHAR [_tcslen(_T("-----END PGP PUBLIC KEY BLOCK-----")) + 1];
+ end = (TCHAR*)mir_alloc(sizeof( TCHAR) * (_tcslen(_T("-----END PGP PUBLIC KEY BLOCK-----")) + 1));
_tcscpy(end, _T("-----END PGP PUBLIC KEY BLOCK-----"));
}
else if(((ws2 = key_buf.find(_T("-----END PGP PRIVATE KEY BLOCK-----"))) != wstring::npos) && ((ws1 = key_buf.find(_T("-----BEGIN PGP PRIVATE KEY BLOCK-----"))) != wstring::npos))
{
- begin = new TCHAR [_tcslen(_T("-----BEGIN PGP PRIVATE KEY BLOCK-----")) + 1];
+ begin = (TCHAR*)mir_alloc(sizeof(TCHAR) * (_tcslen(_T("-----BEGIN PGP PRIVATE KEY BLOCK-----")) + 1));
_tcscpy(begin, _T("-----BEGIN PGP PRIVATE KEY BLOCK-----"));
- end = new TCHAR [_tcslen(_T("-----END PGP PRIVATE KEY BLOCK-----")) + 1];
+ end = (TCHAR*)mir_alloc(sizeof(TCHAR) * (_tcslen(_T("-----END PGP PRIVATE KEY BLOCK-----")) + 1));
_tcscpy(end, _T("-----END PGP PRIVATE KEY BLOCK-----"));
}
else
@@ -944,7 +945,7 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP else
DBWriteContactSettingTString(hContact, szGPGModuleName, "GPGPubKey", key_buf.substr(ws1,ws2-ws1).c_str());
}
- tmp = new TCHAR [key_buf.length()+1];
+ tmp = (TCHAR*)mir_alloc(sizeof( TCHAR) * (key_buf.length()+1));
_tcscpy(tmp, key_buf.substr(ws1,ws2-ws1).c_str());
{ //gpg execute block
wstring cmd;
@@ -1030,7 +1031,7 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP char *tmp2;
string::size_type s = output.find("gpg: key ") + strlen("gpg: key ");
string::size_type s2 = output.find(":", s);
- tmp2 = new char [output.substr(s,s2-s).length()+1];
+ tmp2 = (char*)mir_alloc(output.substr(s,s2-s).length()+1);
strcpy(tmp2, output.substr(s,s2-s).c_str());
mir_utf8decode(tmp2, 0);
{
@@ -1072,7 +1073,7 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP s2 = output.find("<", s);
if(s2 != string::npos)
{
- tmp2 = new char [output.substr(s,s2-s-1).length()+1];
+ tmp2 = (char*)mir_alloc(output.substr(s,s2-s-1).length()+1);
strcpy(tmp2, output.substr(s,s2-s-1).c_str());
mir_utf8decode(tmp2, 0);
if(hContact)
@@ -1167,7 +1168,7 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP }
else
{
- tmp2 = new char [output.substr(s2,s-s2).length()+1];
+ tmp2 = (char*)mir_alloc(output.substr(s2,s-s2).length()+1);
strcpy(tmp2, output.substr(s2,s-s2).c_str());
mir_utf8decode(tmp2, 0);
if(hContact)
diff --git a/src/utilities.cpp b/src/utilities.cpp index 2207213..242ccc4 100755 --- a/src/utilities.cpp +++ b/src/utilities.cpp @@ -23,9 +23,9 @@ TCHAR* __stdcall UniGetContactSettingUtf(HANDLE hContact, const char *szModule,c DBVARIANT dbv = {DBVT_DELETED}; TCHAR* szRes; if (DBGetContactSettingTString(hContact, szModule, szSetting, &dbv)) - return _tcsdup(szDef); + return mir_tstrdup(szDef); if(dbv.pszVal) - szRes = _tcsdup(dbv.ptszVal); + szRes = mir_tstrdup(dbv.ptszVal); DBFreeVariant(&dbv); return szRes; } @@ -35,9 +35,9 @@ char* __stdcall UniGetContactSettingUtf(HANDLE hContact, const char *szModule,co DBVARIANT dbv = {DBVT_DELETED}; char* szRes; if (DBGetContactSettingString(hContact, szModule, szSetting, &dbv)) - return _strdup(szDef); + return mir_strdup(szDef); if(dbv.pszVal) - szRes = _strdup(dbv.pszVal); + szRes = mir_strdup(dbv.pszVal); DBFreeVariant(&dbv); return szRes; } @@ -1089,14 +1089,14 @@ bool isGPGValid() else { mir_free(tmp); - TCHAR *path = new TCHAR [MAX_PATH]; - char *mir_path = new char [MAX_PATH]; + TCHAR *path = (TCHAR*)mir_alloc(sizeof(TCHAR)*MAX_PATH); + char *mir_path = (char*)mir_alloc(MAX_PATH); CallService(MS_UTILS_PATHTOABSOLUTE, (WPARAM)"\\", (LPARAM)mir_path); SetCurrentDirectoryA(mir_path); tmp = mir_a2t(mir_path); mir_free(mir_path); - mir_realloc(path, (_tcslen(path)+128)*sizeof(TCHAR)); - TCHAR *gpg_path = new TCHAR [MAX_PATH]; + //mir_realloc(path, (_tcslen(path)+64)*sizeof(TCHAR)); + TCHAR *gpg_path = (TCHAR*)mir_alloc(sizeof(TCHAR)*MAX_PATH); _tcscpy(gpg_path, tmp); _tcscat(gpg_path, _T("\\GnuPG\\gpg.exe")); mir_free(tmp); @@ -1106,8 +1106,8 @@ bool isGPGValid() _tcscpy(path, _T("GnuPG\\gpg.exe")); } mir_free(gpg_path); - tmp = mir_wstrdup(path); - delete [] path; + tmp = mir_tstrdup(path); + mir_free(path); } DWORD len = MAX_PATH; if(gpg_exists) @@ -1137,14 +1137,15 @@ bool isGPGValid() if(p1 == string::npos) is_valid = false; } - mir_free(tmp); + mir_free(tmp); tmp = NULL; if(!gpg_exists) { wstring path_ = _wgetenv(_T("APPDATA")); path_ += _T("\\GnuPG"); tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", (TCHAR*)path_.c_str()); } - mir_free(tmp); + if(tmp) + mir_free(tmp); return is_valid; } |