diff options
author | Tobias Weimer <wishmaster51@googlemail.com> | 2015-09-16 18:52:29 +0000 |
---|---|---|
committer | Tobias Weimer <wishmaster51@googlemail.com> | 2015-09-16 18:52:29 +0000 |
commit | 3c00a78191f46c10f036c789a9ef358f0e049d61 (patch) | |
tree | 96741c418983d401ebba418b579793c8c4959d30 /protocols/Tox/src/tox_profile.cpp | |
parent | ab46b98479555c7106087f7d62b6c89f320ca311 (diff) |
Tox:
- attempt to fix numerous crashes
git-svn-id: http://svn.miranda-ng.org/main/trunk@15366 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tox/src/tox_profile.cpp')
-rw-r--r-- | protocols/Tox/src/tox_profile.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/protocols/Tox/src/tox_profile.cpp b/protocols/Tox/src/tox_profile.cpp index 796cdf6606..d103736466 100644 --- a/protocols/Tox/src/tox_profile.cpp +++ b/protocols/Tox/src/tox_profile.cpp @@ -21,9 +21,6 @@ bool CToxProto::LoadToxProfile(Tox_Options *options) logger->Log(__FUNCTION__": loading tox profile");
mir_cslock locker(profileLock);
-
- size_t size = 0;
- uint8_t *data = NULL;
ptrT profilePath(GetToxProfilePath());
if (!IsFileExists(profilePath))
@@ -38,16 +35,16 @@ bool CToxProto::LoadToxProfile(Tox_Options *options) }
fseek(profile, 0, SEEK_END);
- size = ftell(profile);
+ long size = ftell(profile);
rewind(profile);
if (size < 0)
{
fclose(profile);
- size = 0;
+ return false;
}
- data = (uint8_t*)mir_calloc(size);
- if (fread((char*)data, sizeof(char), size, profile) != size)
+ uint8_t *data = (uint8_t*)mir_calloc(size);
+ if (fread((char*)data, sizeof(char), size, profile) != (size_t)size)
{
fclose(profile);
ShowNotification(TranslateT("Unable to read Tox profile"), MB_ICONERROR);
@@ -57,7 +54,7 @@ bool CToxProto::LoadToxProfile(Tox_Options *options) }
fclose(profile);
- if (data && tox_is_data_encrypted(data))
+ if (tox_is_data_encrypted(data))
{
pass_ptrA password(mir_utf8encodeW(pass_ptrT(getTStringA("Password"))));
if (password == NULL || mir_strlen(password) == 0)
|