summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-06-21 17:22:27 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-06-21 17:22:27 +0000
commit4267ebcb5fd90819de23064019d1dd214e76b5ef (patch)
tree01f66ab2149436f7af74577099f6b620d8b469ca
parent6ba9043d83f28cf2b6c7d10c5d5495d15de344c1 (diff)
fix for crash on start in Skype
git-svn-id: http://svn.miranda-ng.org/main/trunk@5085 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--protocols/Skype/src/skype_runtime.cpp17
1 files changed, 8 insertions, 9 deletions
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<BYTE> 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;
}