diff options
Diffstat (limited to 'plugins/SmileyAdd')
-rw-r--r-- | plugins/SmileyAdd/src/customsmiley.cpp | 12 | ||||
-rw-r--r-- | plugins/SmileyAdd/src/smileys.cpp | 28 |
2 files changed, 19 insertions, 21 deletions
diff --git a/plugins/SmileyAdd/src/customsmiley.cpp b/plugins/SmileyAdd/src/customsmiley.cpp index 4c0a75a11a..a41920d140 100644 --- a/plugins/SmileyAdd/src/customsmiley.cpp +++ b/plugins/SmileyAdd/src/customsmiley.cpp @@ -77,14 +77,14 @@ bool SmileyCType::CreateTriggerText(char* text) int len = (int)strlen(text);
if (len == 0) return false;
- int reslen = Netlib_GetBase64DecodedBufferSize(len)+1;
- char* res = (char*)alloca(reslen);
-
- NETLIBBASE64 nlb = { text, len, ( PBYTE )res, reslen };
- if (!CallService(MS_NETLIB_BASE64DECODE, 0, LPARAM( &nlb ))) return false;
- res[nlb.cbDecoded] = 0;
+ unsigned reslen;
+ char* res = (char*)mir_base64_decode(text, &reslen);
+ if (res == NULL)
+ return false;
+ char save = res[reslen]; res[reslen] = 0; // safe because of mir_alloc
TCHAR *txt = mir_utf8decodeT(res);
+ res[reslen] = save;
if (txt == NULL) return false;
diff --git a/plugins/SmileyAdd/src/smileys.cpp b/plugins/SmileyAdd/src/smileys.cpp index b63cbf4223..e81bc18c28 100644 --- a/plugins/SmileyAdd/src/smileys.cpp +++ b/plugins/SmileyAdd/src/smileys.cpp @@ -511,26 +511,24 @@ static void DecodeHTML(bkstring& str) }
-static IStream* DecodeBase64Data(const char* data)
+static IStream* DecodeBase64Data(const char* pData)
{
- NETLIBBASE64 nlb64;
- nlb64.pszEncoded = (char*)data;
- nlb64.cchEncoded = (int)strlen(data);
- nlb64.cbDecoded = Netlib_GetBase64DecodedBufferSize(nlb64.cchEncoded);
-
- IStream* pStream = NULL;
+ unsigned dataLen;
+ ptrA data((char*)mir_base64_decode(pData, &dataLen));
+ if (data == NULL)
+ return NULL;
// Read image list
- HGLOBAL hBuffer = GlobalAlloc(GMEM_MOVEABLE, nlb64.cbDecoded);
- if (hBuffer)
- {
- nlb64.pbDecoded = (PBYTE)GlobalLock(hBuffer);
- CallService(MS_NETLIB_BASE64DECODE, 0, (LPARAM)&nlb64);
- GlobalUnlock(hBuffer);
+ HGLOBAL hBuffer = GlobalAlloc(GMEM_MOVEABLE, dataLen);
+ if (!hBuffer)
+ return NULL;
- CreateStreamOnHGlobal(hBuffer, TRUE, &pStream);
- }
+ void *dst = GlobalLock(hBuffer);
+ memcpy(dst, data, dataLen);
+ GlobalUnlock(hBuffer);
+ IStream *pStream = NULL;
+ CreateStreamOnHGlobal(hBuffer, TRUE, &pStream);
return pStream;
}
|