From 4267ebcb5fd90819de23064019d1dd214e76b5ef Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 21 Jun 2013 17:22:27 +0000 Subject: fix for crash on start in Skype git-svn-id: http://svn.miranda-ng.org/main/trunk@5085 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Skype/src/skype_runtime.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'protocols/Skype/src') diff --git a/protocols/Skype/src/skype_runtime.cpp b/protocols/Skype/src/skype_runtime.cpp index 9b605d3488..bd6fe46a49 100644 --- a/protocols/Skype/src/skype_runtime.cpp +++ b/protocols/Skype/src/skype_runtime.cpp @@ -22,24 +22,23 @@ char *CSkypeProto::LoadKeyPair() if (length == 0) return NULL; - char* pData = new char[length + 1]; + char* pData = (char*)_alloca(length + 1); ::memcpy(pData, pLockedResource, length); pData[length] = 0; - unsigned char *tmpD = (unsigned char *)::mir_base64_decode(pData, NULL); - unsigned char *result = (unsigned char *)::mir_alloc(length*2); - delete [] pData; + unsigned decodedLen; + mir_ptr tmpD((BYTE*)::mir_base64_decode(pData, &decodedLen)); + BYTE *result = (BYTE*)::mir_alloc(decodedLen+17); aes_context ctx; char *key = (char*)::mir_base64_decode(MY_KEY, NULL); - ::aes_set_key(&ctx, (unsigned char *)key, 128); + ::aes_set_key(&ctx, (BYTE*)key, 128); ::mir_free(key); - for (int i = 0; i < length; i += 16) - aes_decrypt(&ctx, tmpD + i, result + i); + for (unsigned i = 0; i < decodedLen; i += 16) + aes_decrypt(&ctx, &tmpD[i], &result[i]); - ::mir_free(tmpD); - result[length] = 0; + result[decodedLen] = 0; return (char *)result; } -- cgit v1.2.3