summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-10-08 12:39:42 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-10-08 12:39:42 +0300
commitfcb451edf5072a325fcd91e005f4348bdeec5cb4 (patch)
tree18888619136c8521f455ed5e49e260112a1e80ed /protocols
parentcecf1d818a3ac07965d70fe95f33b9ac2d43804b (diff)
Twitter: fix for rare crash in avatar reader
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Twitter/src/connection.cpp3
-rw-r--r--protocols/Twitter/src/utility.cpp3
2 files changed, 3 insertions, 3 deletions
diff --git a/protocols/Twitter/src/connection.cpp b/protocols/Twitter/src/connection.cpp
index f7ce4421a2..6a35d2002b 100644
--- a/protocols/Twitter/src/connection.cpp
+++ b/protocols/Twitter/src/connection.cpp
@@ -299,8 +299,7 @@ void CTwitterProto::UpdateAvatarWorker(void *p)
debugLogA("***** Updating avatar: %s", data->url.c_str());
mir_cslock lck(avatar_lock_);
- if (Miranda_IsTerminated()) // if miranda is shutting down...
- {
+ if (Miranda_IsTerminated()) { // if miranda is shutting down...
debugLogA("***** Terminating avatar update early: %s", data->url.c_str());
return;
}
diff --git a/protocols/Twitter/src/utility.cpp b/protocols/Twitter/src/utility.cpp
index 7e4c269a79..b7198723e2 100644
--- a/protocols/Twitter/src/utility.cpp
+++ b/protocols/Twitter/src/utility.cpp
@@ -92,7 +92,8 @@ bool save_url(HNETLIBUSER hNetlib, const CMStringA &url, const CMStringW &filena
// Write to file
FILE *f = _wfopen(filename, L"wb");
- fwrite(resp->pData, 1, resp->dataLength, f);
+ if (resp->pData && !IsBadReadPtr(resp->pData, resp->dataLength))
+ fwrite(resp->pData, 1, resp->dataLength, f);
fclose(f);
return true;