diff options
author | Robert Pösel <robyer@seznam.cz> | 2015-03-05 14:36:10 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2015-03-05 14:36:10 +0000 |
commit | 68c31fd58da09d3f4f0b4c7b78a53f83cc5f9ffb (patch) | |
tree | 83be1c5e5654087223abbfbf62e26f4b83ac93f0 /protocols/Steam/src/steam_queue.cpp | |
parent | ac74cfab81e32d85eb4344a4ca9d2f400b625583 (diff) |
Steam: Fix potential memleaks when proto tries to do request when it became (or is already) offline
git-svn-id: http://svn.miranda-ng.org/main/trunk@12325 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Steam/src/steam_queue.cpp')
-rw-r--r-- | protocols/Steam/src/steam_queue.cpp | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/protocols/Steam/src/steam_queue.cpp b/protocols/Steam/src/steam_queue.cpp index a134aa9890..d5eb363ca0 100644 --- a/protocols/Steam/src/steam_queue.cpp +++ b/protocols/Steam/src/steam_queue.cpp @@ -45,9 +45,15 @@ void CSteamProto::StopQueue() {
mir_cslock lock(requests_queue_lock);
- int count = requestsQueue.getCount();
- while (count > 0)
- requestsQueue.remove(--count);
+ while (requestsQueue.getCount() > 0)
+ {
+ QueueItem *item = requestsQueue[0];
+ requestsQueue.remove(0);
+
+ // We call ExecuteRequest() but as we have set isTerminated=true it will only run callback to behave correctly (free arguments, raise errors, etc.)
+ if (item != NULL)
+ ExecuteRequest(item);
+ }
}
// logoff
@@ -76,6 +82,13 @@ void CSteamProto::PushRequest(SteamWebApi::HttpRequest *request, RESPONSE respon void CSteamProto::PushRequest(SteamWebApi::HttpRequest *request, RESPONSE response, void *arg)
{
+ if (isTerminated || !IsOnline())
+ {
+ // Call response callback so it can react properly (free arguments, raise errors, etc.)
+ if (response != NULL)
+ (this->*(response))(NULL, arg);
+ }
+
if (isTerminated)
return;
@@ -91,6 +104,13 @@ void CSteamProto::PushRequest(SteamWebApi::HttpRequest *request, RESPONSE respon void CSteamProto::ExecuteRequest(QueueItem *item)
{
+ if (isTerminated || !IsOnline())
+ {
+ // Call response callback so it can react properly (free arguments, raise errors, etc.)
+ if (item->responseCallback != NULL)
+ (this->*(item->responseCallback))(NULL, item->arg);
+ }
+
if (isTerminated)
return;
|