diff options
author | George Hazan <ghazan@miranda.im> | 2019-01-06 17:20:24 +0200 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-01-06 17:20:24 +0200 |
commit | 80ccccc6c8889ef287e78e0cf31a268ec2a39942 (patch) | |
tree | 620b6849e0ff2bd9ebf13aee551c0c1c944051a1 /src | |
parent | ac34a82d07d24856aee5629fec42ce9d0f33800d (diff) |
ICQ: crash fix
Diffstat (limited to 'src')
-rw-r--r-- | src/mir_app/src/proto_utils.cpp | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/src/mir_app/src/proto_utils.cpp b/src/mir_app/src/proto_utils.cpp index 666211e6ab..e1f3d803c3 100644 --- a/src/mir_app/src/proto_utils.cpp +++ b/src/mir_app/src/proto_utils.cpp @@ -320,29 +320,31 @@ MIR_APP_DLL(int) ProtoGetAvatarFormat(const wchar_t *ptszFileName) MIR_APP_DLL(int) ProtoGetBufferFormat(const void *pBuffer, const wchar_t **ptszExtension)
{
- if (!memcmp(pBuffer, "\x89PNG", 4)) {
- if (ptszExtension) *ptszExtension = L".png";
- return PA_FORMAT_PNG;
- }
+ if (pBuffer != nullptr) {
+ if (!memcmp(pBuffer, "\x89PNG", 4)) {
+ if (ptszExtension) *ptszExtension = L".png";
+ return PA_FORMAT_PNG;
+ }
- if (!memcmp(pBuffer, "GIF8", 4)) {
- if (ptszExtension) *ptszExtension = L".gif";
- return PA_FORMAT_GIF;
- }
+ if (!memcmp(pBuffer, "GIF8", 4)) {
+ if (ptszExtension) *ptszExtension = L".gif";
+ return PA_FORMAT_GIF;
+ }
- if (!memicmp(pBuffer, "<?xml", 5)) {
- if (ptszExtension) *ptszExtension = L".xml";
- return PA_FORMAT_XML;
- }
+ if (!memicmp(pBuffer, "<?xml", 5)) {
+ if (ptszExtension) *ptszExtension = L".xml";
+ return PA_FORMAT_XML;
+ }
- if (!memcmp(pBuffer, "\xFF\xD8\xFF\xE0", 4) || !memcmp(pBuffer, "\xFF\xD8\xFF\xE1", 4)) {
- if (ptszExtension) *ptszExtension = L".jpg";
- return PA_FORMAT_JPEG;
- }
+ if (!memcmp(pBuffer, "\xFF\xD8\xFF\xE0", 4) || !memcmp(pBuffer, "\xFF\xD8\xFF\xE1", 4)) {
+ if (ptszExtension) *ptszExtension = L".jpg";
+ return PA_FORMAT_JPEG;
+ }
- if (!memcmp(pBuffer, "BM", 2)) {
- if (ptszExtension) *ptszExtension = L".bmp";
- return PA_FORMAT_BMP;
+ if (!memcmp(pBuffer, "BM", 2)) {
+ if (ptszExtension) *ptszExtension = L".bmp";
+ return PA_FORMAT_BMP;
+ }
}
if (ptszExtension) *ptszExtension = L"";
|