From 3a9e5bf2542f40686e9df0adac735bf6932ff8fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Sat, 22 Nov 2014 12:47:44 +0000 Subject: Steam: Fix crashes on login and on other occasions git-svn-id: http://svn.miranda-ng.org/main/trunk@11035 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Steam/src/steam_account.cpp | 18 ++++++++++++++++++ protocols/Steam/src/steam_contacts.cpp | 9 +++++++++ 2 files changed, 27 insertions(+) diff --git a/protocols/Steam/src/steam_account.cpp b/protocols/Steam/src/steam_account.cpp index 274ae4699f..7bf2645fe9 100644 --- a/protocols/Steam/src/steam_account.cpp +++ b/protocols/Steam/src/steam_account.cpp @@ -16,6 +16,9 @@ bool CSteamProto::IsMe(const char *steamId) void CSteamProto::OnGotRsaKey(const NETLIBHTTPREQUEST *response, void *arg) { + if (response == NULL) + return; + // load rsa key parts JSONNODE *root = json_parse(response->pData), *node; if (!root) return; @@ -69,6 +72,11 @@ void CSteamProto::OnGotRsaKey(const NETLIBHTTPREQUEST *response, void *arg) void CSteamProto::OnAuthorization(const NETLIBHTTPREQUEST *response, void *arg) { + if (response == NULL) { + SetStatus(ID_STATUS_OFFLINE); + return; + } + JSONNODE *root = json_parse(response->pData), *node; node = json_get(root, "success"); @@ -195,6 +203,9 @@ void CSteamProto::OnAuthorization(const NETLIBHTTPREQUEST *response, void *arg) void CSteamProto::OnGotSession(const NETLIBHTTPREQUEST *response, void *arg) { + if (response == NULL) + return; + for (int i = 0; i < response->headersCount; i++) { if (lstrcmpiA(response->headers[i].szName, "Set-Cookie")) @@ -211,6 +222,13 @@ void CSteamProto::OnGotSession(const NETLIBHTTPREQUEST *response, void *arg) void CSteamProto::OnLoggedOn(const NETLIBHTTPREQUEST *response, void *arg) { + if (response == NULL) { + // set status to offline + m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE; + ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_CONNECTING, ID_STATUS_OFFLINE); + return; + } + JSONNODE *root = json_parse(response->pData), *node; node = json_get(root, "error"); diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp index 0d8cfb5472..630241dcd7 100644 --- a/protocols/Steam/src/steam_contacts.cpp +++ b/protocols/Steam/src/steam_contacts.cpp @@ -182,6 +182,9 @@ MCONTACT CSteamProto::AddContact(const char *steamId, bool isTemporary) void CSteamProto::OnGotFriendList(const NETLIBHTTPREQUEST *response, void *arg) { + if (response == NULL) + return; + JSONNODE *root = json_parse(response->pData), *node, *child; if (root == NULL) @@ -246,6 +249,9 @@ void CSteamProto::OnGotFriendList(const NETLIBHTTPREQUEST *response, void *arg) void CSteamProto::OnGotBlockList(const NETLIBHTTPREQUEST *response, void *arg) { + if (response == NULL) + return; + JSONNODE *root = json_parse(response->pData), *node, *child; if (root == NULL) @@ -287,6 +293,9 @@ void CSteamProto::OnGotBlockList(const NETLIBHTTPREQUEST *response, void *arg) void CSteamProto::OnGotUserSummaries(const NETLIBHTTPREQUEST *response, void *arg) { + if (response == NULL) + return; + JSONNODE *root = json_parse(response->pData), *node, *item; node = json_get(root, "players"); -- cgit v1.2.3