diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-04-10 18:26:49 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-04-10 18:26:49 +0000 |
commit | e372b5c98c28088a666e8f8050c0ec57e7b326de (patch) | |
tree | 5556e072c2b649f598c51404b184880f928af0f6 /protocols/SkypeWeb/src/skype_avatars.cpp | |
parent | 9cecda91ac7e563b14fdba9d9cd5feea3faccf69 (diff) |
SkypeWeb: Fixed some bugs from coverity
git-svn-id: http://svn.miranda-ng.org/main/trunk@12751 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb/src/skype_avatars.cpp')
-rw-r--r-- | protocols/SkypeWeb/src/skype_avatars.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/protocols/SkypeWeb/src/skype_avatars.cpp b/protocols/SkypeWeb/src/skype_avatars.cpp index d3282bb565..3f003b9a5e 100644 --- a/protocols/SkypeWeb/src/skype_avatars.cpp +++ b/protocols/SkypeWeb/src/skype_avatars.cpp @@ -172,8 +172,6 @@ INT_PTR CSkypeProto::SvcSetMyAvatar(WPARAM wParam, LPARAM lParam) return -1;
}
- size_t length;
- char *data;
FILE *hFile = _tfopen(path, L"rb");
if (!hFile)
{
@@ -182,23 +180,30 @@ INT_PTR CSkypeProto::SvcSetMyAvatar(WPARAM wParam, LPARAM lParam) }
fseek(hFile, 0, SEEK_END);
- length = ftell(hFile);
+ size_t length = ftell(hFile);
+ if (length == -1)
+ {
+ debugLogA("CSkypeProto::SvcSetMyAvatar: failed to get avatar file size");
+ fclose(hFile);
+ return -1;
+ }
rewind(hFile);
- data = (char*)mir_alloc(length);
- size_t read = fread(data, sizeof(char), length, hFile);
- if (read != length)
+ char *data = (char*)mir_alloc(length);
+ if (fread(data, sizeof(char), length, hFile) != length)
{
- fclose(hFile);
debugLogA("CSkypeProto::SvcSetMyAvatar: failed to read avatar file");
+ mir_free(data);
+ fclose(hFile);
return -1;
}
fclose(hFile);
-
ptrA token(getStringA("TokenSecret"));
ptrA skypename(getStringA(SKYPE_SETTINGS_ID));
PushRequest(new SetAvatarRequest(token, skypename, data, length), &CSkypeProto::OnSentAvatar);
+
+ mir_free(data);
}
else
{
|