diff options
author | Robert Pösel <robyer@seznam.cz> | 2014-11-28 12:58:45 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2014-11-28 12:58:45 +0000 |
commit | 2de6603f69b343c3245043ab4c05292a617bd9ba (patch) | |
tree | a0930902daee55144d130a6bc77f8a22fedca4cc /protocols | |
parent | 8817909629b3e0881672a7b7324fc7c583c331ad (diff) |
Use JSONROOT everywhere to simplify code and fix memleaks (in Dropbox and Steam)
git-svn-id: http://svn.miranda-ng.org/main/trunk@11130 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/FacebookRM/src/json.cpp | 43 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/avatar.cpp | 3 | ||||
-rw-r--r-- | protocols/Steam/src/Steam/crypto.h | 4 | ||||
-rw-r--r-- | protocols/Steam/src/Steam/message.h | 4 | ||||
-rw-r--r-- | protocols/Steam/src/steam_account.cpp | 35 | ||||
-rw-r--r-- | protocols/Steam/src/steam_contacts.cpp | 76 | ||||
-rw-r--r-- | protocols/Steam/src/steam_messages.cpp | 7 | ||||
-rw-r--r-- | protocols/Steam/src/steam_pooling.cpp | 6 |
8 files changed, 62 insertions, 116 deletions
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index 4f7649475d..445d1e767d 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -27,19 +27,17 @@ int facebook_json_parser::parse_buddy_list(void* data, List::List< facebook_user facebook_user* current = NULL; std::string jsonData = static_cast< std::string* >(data)->substr(9); - JSONNODE *root = json_parse(jsonData.c_str()); + JSONROOT root(jsonData.c_str()); if (root == NULL) return EXIT_FAILURE; JSONNODE *payload = json_get(root, "payload"); if (payload == NULL) { - json_delete(root); return EXIT_FAILURE; } JSONNODE *list = json_get(payload, "buddy_list"); if (list == NULL) { - json_delete(root); return EXIT_FAILURE; } @@ -157,7 +155,6 @@ int facebook_json_parser::parse_buddy_list(void* data, List::List< facebook_user } } - json_delete(root); return EXIT_SUCCESS; } @@ -203,13 +200,12 @@ int facebook_json_parser::parse_friends(void* data, std::map< std::string, faceb { std::string jsonData = static_cast< std::string* >(data)->substr(9); - JSONNODE *root = json_parse(jsonData.c_str()); + JSONROOT root(jsonData.c_str()); if (root == NULL) return EXIT_FAILURE; JSONNODE *payload = json_get(root, "payload"); if (payload == NULL) { - json_delete(root); return EXIT_FAILURE; } @@ -222,7 +218,6 @@ int facebook_json_parser::parse_friends(void* data, std::map< std::string, faceb friends->insert(std::make_pair(fbu->user_id, fbu)); } - json_delete(root); return EXIT_SUCCESS; } @@ -231,19 +226,17 @@ int facebook_json_parser::parse_notifications(void *data, std::map< std::string, { std::string jsonData = static_cast< std::string* >(data)->substr(9); - JSONNODE *root = json_parse(jsonData.c_str()); + JSONROOT root(jsonData.c_str()); if (root == NULL) return EXIT_FAILURE; JSONNODE *payload = json_get(root, "payload"); if (payload == NULL) { - json_delete(root); return EXIT_FAILURE; } JSONNODE *list = json_get(payload, "notifications"); if (list == NULL) { - json_delete(root); return EXIT_FAILURE; } @@ -284,7 +277,6 @@ int facebook_json_parser::parse_notifications(void *data, std::map< std::string, delete notification; } - json_delete(root); return EXIT_SUCCESS; } @@ -417,13 +409,12 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa std::string jsonData = static_cast< std::string* >(data)->substr(9); - JSONNODE *root = json_parse(jsonData.c_str()); + JSONROOT root(jsonData.c_str()); if (root == NULL) return EXIT_FAILURE; JSONNODE *ms = json_get(root, "ms"); if (ms == NULL) { - json_delete(root); return EXIT_FAILURE; } @@ -809,7 +800,6 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa continue; } - json_delete(root); return EXIT_SUCCESS; } @@ -817,19 +807,17 @@ int facebook_json_parser::parse_unread_threads(void* data, std::vector< std::str { std::string jsonData = static_cast< std::string* >(data)->substr(9); - JSONNODE *root = json_parse(jsonData.c_str()); + JSONROOT root(jsonData.c_str()); if (root == NULL) return EXIT_FAILURE; JSONNODE *payload = json_get(root, "payload"); if (payload == NULL) { - json_delete(root); return EXIT_FAILURE; } JSONNODE *unread_threads = json_get(payload, "unread_thread_ids"); if (unread_threads == NULL) { - json_delete(root); return EXIT_FAILURE; } @@ -848,7 +836,6 @@ int facebook_json_parser::parse_unread_threads(void* data, std::vector< std::str } } - json_delete(root); return EXIT_SUCCESS; } @@ -856,20 +843,18 @@ int facebook_json_parser::parse_thread_messages(void* data, std::vector< faceboo { std::string jsonData = static_cast< std::string* >(data)->substr(9); - JSONNODE *root = json_parse(jsonData.c_str()); + JSONROOT root(jsonData.c_str()); if (root == NULL) return EXIT_FAILURE; JSONNODE *payload = json_get(root, "payload"); if (payload == NULL) { - json_delete(root); return EXIT_FAILURE; } JSONNODE *actions = json_get(payload, "actions"); JSONNODE *threads = json_get(payload, "threads"); if (actions == NULL || threads == NULL) { - json_delete(root); return EXIT_FAILURE; } @@ -1004,7 +989,6 @@ int facebook_json_parser::parse_thread_messages(void* data, std::vector< faceboo messages->push_back(message); } - json_delete(root); return EXIT_SUCCESS; } @@ -1012,19 +996,17 @@ int facebook_json_parser::parse_thread_info(void* data, std::string* user_id) { std::string jsonData = static_cast< std::string* >(data)->substr(9); - JSONNODE *root = json_parse(jsonData.c_str()); + JSONROOT root(jsonData.c_str()); if (root == NULL) return EXIT_FAILURE; JSONNODE *payload = json_get(root, "payload"); if (payload == NULL) { - json_delete(root); return EXIT_FAILURE; } JSONNODE *threads = json_get(payload, "threads"); if (threads == NULL) { - json_delete(root); return EXIT_FAILURE; } @@ -1045,7 +1027,6 @@ int facebook_json_parser::parse_thread_info(void* data, std::string* user_id) *user_id = id; } - json_delete(root); return EXIT_SUCCESS; } @@ -1054,19 +1035,17 @@ int facebook_json_parser::parse_user_info(void* data, facebook_user* fbu) { std::string jsonData = static_cast< std::string* >(data)->substr(9); - JSONNODE *root = json_parse(jsonData.c_str()); + JSONROOT root(jsonData.c_str()); if (root == NULL) return EXIT_FAILURE; JSONNODE *payload = json_get(root, "payload"); if (payload == NULL) { - json_delete(root); return EXIT_FAILURE; } JSONNODE *profiles = json_get(payload, "profiles"); if (profiles == NULL) { - json_delete(root); return EXIT_FAILURE; } @@ -1083,7 +1062,6 @@ int facebook_json_parser::parse_user_info(void* data, facebook_user* fbu) } } - json_delete(root); return EXIT_SUCCESS; } @@ -1091,20 +1069,18 @@ int facebook_json_parser::parse_chat_info(void* data, facebook_chatroom* fbc) { std::string jsonData = static_cast< std::string* >(data)->substr(9); - JSONNODE *root = json_parse(jsonData.c_str()); + JSONROOT root(jsonData.c_str()); if (root == NULL) return EXIT_FAILURE; JSONNODE *payload = json_get(root, "payload"); if (payload == NULL) { - json_delete(root); return EXIT_FAILURE; } //JSONNODE *actions = json_get(payload, "actions"); JSONNODE *threads = json_get(payload, "threads"); if (/*actions == NULL || */threads == NULL) { - json_delete(root); return EXIT_FAILURE; } @@ -1155,6 +1131,5 @@ int facebook_json_parser::parse_chat_info(void* data, facebook_chatroom* fbc) fbc->chat_name = json_as_string(name_); } - json_delete(root); return EXIT_SUCCESS; } diff --git a/protocols/Gadu-Gadu/src/avatar.cpp b/protocols/Gadu-Gadu/src/avatar.cpp index defabb11e5..e3f871cfdf 100644 --- a/protocols/Gadu-Gadu/src/avatar.cpp +++ b/protocols/Gadu-Gadu/src/avatar.cpp @@ -104,7 +104,7 @@ bool GGPROTO::getAvatarFileInfo(uin_t uin, char **avatarurl, char **avatarts) } else if (strncmp(resp->pData, "{\"result\":", 10) == 0){
//if this url returns json data (11.2013 gg convention)
- JSONNODE *respJSON = json_parse(resp->pData);
+ JSONROOT respJSON(resp->pData);
if (respJSON != NULL) {
JSONNODE* respJSONavatars = json_get(json_get(json_get(json_get(respJSON, "result"), "users"), "user"), "avatars");
if (respJSONavatars != NULL) {
@@ -117,7 +117,6 @@ bool GGPROTO::getAvatarFileInfo(uin_t uin, char **avatarurl, char **avatarts) *avatarts = mir_t2a(respJSONtimestamp);
}
}
- json_delete(respJSON);
}
} else {
diff --git a/protocols/Steam/src/Steam/crypto.h b/protocols/Steam/src/Steam/crypto.h index 553e311cf7..729dc2a591 100644 --- a/protocols/Steam/src/Steam/crypto.h +++ b/protocols/Steam/src/Steam/crypto.h @@ -99,10 +99,10 @@ namespace SteamWebApi if (!response || response->resultCode != HTTP_STATUS_OK)
return;
- JSONNODE *root = json_parse(response->pData), *node;
+ JSONROOT root(response->pData);
if (!root) return;
- node = json_get(root, "success");
+ JSONNODE *node = json_get(root, "success");
if (!json_as_bool(node)) return;
node = json_get(root, "publickey_mod");
diff --git a/protocols/Steam/src/Steam/message.h b/protocols/Steam/src/Steam/message.h index b75d2f7965..b14dff4446 100644 --- a/protocols/Steam/src/Steam/message.h +++ b/protocols/Steam/src/Steam/message.h @@ -65,9 +65,9 @@ namespace SteamWebApi // if ((sendResult->status = (HTTP_STATUS)response->resultCode) != HTTP_STATUS_OK)
// return;
- // JSONNODE *root = json_parse(response->pData), *node;
+ // JSONROOT root(response->pData);
- // node = json_get(root, "error");
+ // JSONNODE *node = json_get(root, "error");
// ptrW error(json_as_string(node));
// if (lstrcmp(error, L"OK"))
diff --git a/protocols/Steam/src/steam_account.cpp b/protocols/Steam/src/steam_account.cpp index fa4cdf1804..b428896fcc 100644 --- a/protocols/Steam/src/steam_account.cpp +++ b/protocols/Steam/src/steam_account.cpp @@ -20,13 +20,12 @@ void CSteamProto::OnGotRsaKey(const NETLIBHTTPREQUEST *response, void *arg) return;
// load rsa key parts
- JSONNODE *root = json_parse(response->pData), *node;
+ JSONROOT root(response->pData);
if (!root)
return;
- node = json_get(root, "success");
+ JSONNODE *node = json_get(root, "success");
if (!json_as_bool(node)) {
- json_delete(root);
return;
}
@@ -45,8 +44,6 @@ void CSteamProto::OnGotRsaKey(const NETLIBHTTPREQUEST *response, void *arg) ptrA base64RsaEncryptedPassword;
ptrA password(getStringA("Password"));
- json_delete(root);
-
DWORD error = 0;
DWORD encryptedSize = 0;
DWORD passwordSize = (DWORD)strlen(password);
@@ -83,9 +80,9 @@ void CSteamProto::OnAuthorization(const NETLIBHTTPREQUEST *response, void *arg) return;
}
- JSONNODE *root = json_parse(response->pData), *node;
+ JSONROOT root(response->pData);
- node = json_get(root, "success");
+ JSONNODE *node = json_get(root, "success");
if (json_as_bool(node) == 0)
{
node = json_get(root, "message");
@@ -94,7 +91,6 @@ void CSteamProto::OnAuthorization(const NETLIBHTTPREQUEST *response, void *arg) {
ShowNotification(TranslateTS(message));
SetStatus(ID_STATUS_OFFLINE);
- json_delete(root);
return;
}
@@ -110,13 +106,7 @@ void CSteamProto::OnAuthorization(const NETLIBHTTPREQUEST *response, void *arg) GuardParam guard;
lstrcpyA(guard.domain, emailDomain);
- if (DialogBoxParam(
- g_hInstance,
- MAKEINTRESOURCE(IDD_GUARD),
- NULL,
- CSteamProto::GuardProc,
- (LPARAM)&guard) != 1) {
- json_delete(root);
+ if (DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_GUARD), NULL, CSteamProto::GuardProc, (LPARAM)&guard) != 1) {
return;
}
@@ -162,7 +152,6 @@ void CSteamProto::OnAuthorization(const NETLIBHTTPREQUEST *response, void *arg) if (res != 1)
{
SetStatus(ID_STATUS_OFFLINE);
- json_delete(root);
return;
}
@@ -175,7 +164,6 @@ void CSteamProto::OnAuthorization(const NETLIBHTTPREQUEST *response, void *arg) &CSteamProto::OnAuthorization);
}
- json_delete(root);
return;
}
@@ -183,12 +171,11 @@ void CSteamProto::OnAuthorization(const NETLIBHTTPREQUEST *response, void *arg) if (!json_as_bool(node))
{
SetStatus(ID_STATUS_OFFLINE);
- json_delete(root);
return;
}
node = json_get(root, "oauth");
- JSONNODE *nroot = json_parse(ptrA(mir_u2a(json_as_string(node))));
+ JSONROOT nroot(ptrA(mir_u2a(json_as_string(node))));
node = json_get(nroot, "steamid");
ptrA steamId(mir_u2a(json_as_string(node)));
@@ -204,9 +191,6 @@ void CSteamProto::OnAuthorization(const NETLIBHTTPREQUEST *response, void *arg) delSetting("Timestamp");
delSetting("EncryptedPassword");
- json_delete(nroot);
- json_delete(root);
-
PushRequest(
new SteamWebApi::GetSessionRequest(token, steamId, cookie),
&CSteamProto::OnGotSession);
@@ -244,9 +228,9 @@ void CSteamProto::OnLoggedOn(const NETLIBHTTPREQUEST *response, void *arg) return;
}
- JSONNODE *root = json_parse(response->pData), *node;
+ JSONROOT root(response->pData);
- node = json_get(root, "error");
+ JSONNODE *node = json_get(root, "error");
ptrW error(json_as_string(node));
if (lstrcmpi(error, L"OK")/* || response->resultCode == HTTP_STATUS_UNAUTHORIZED*/)
{
@@ -256,7 +240,6 @@ void CSteamProto::OnLoggedOn(const NETLIBHTTPREQUEST *response, void *arg) // set status to offline
m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_CONNECTING, ID_STATUS_OFFLINE);
- json_delete(root);
return;
}
@@ -266,8 +249,6 @@ void CSteamProto::OnLoggedOn(const NETLIBHTTPREQUEST *response, void *arg) node = json_get(root, "message");
setDword("MessageID", json_as_int(node));
- json_delete(root);
-
// load contact list
ptrA token(getStringA("TokenSecret"));
ptrA steamId(getStringA("SteamID"));
diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp index 797ae0e166..884c1f9c59 100644 --- a/protocols/Steam/src/steam_contacts.cpp +++ b/protocols/Steam/src/steam_contacts.cpp @@ -185,20 +185,19 @@ void CSteamProto::OnGotFriendList(const NETLIBHTTPREQUEST *response, void *arg) if (response == NULL)
return;
- JSONNODE *root = json_parse(response->pData), *node, *child;
-
+ JSONROOT root(response->pData);
if (root == NULL)
return;
std::string steamIds;
- node = json_get(root, "friends");
- root = json_as_array(node);
- if (root != NULL)
+ JSONNODE *node = json_get(root, "friends");
+ JSONNODE *nroot = json_as_array(node);
+ if (nroot != NULL)
{
- for (size_t i = 0; i < json_size(root); i++)
+ for (size_t i = 0; i < json_size(nroot); i++)
{
- child = json_at(root, i);
+ JSONNODE *child = json_at(nroot, i);
if (child == NULL)
break;
@@ -236,8 +235,6 @@ void CSteamProto::OnGotFriendList(const NETLIBHTTPREQUEST *response, void *arg) }
}
- json_delete(root);
-
if (!steamIds.empty())
{
steamIds.pop_back();
@@ -254,20 +251,19 @@ void CSteamProto::OnGotBlockList(const NETLIBHTTPREQUEST *response, void *arg) if (response == NULL)
return;
- JSONNODE *root = json_parse(response->pData), *node, *child;
-
+ JSONROOT root(response->pData);
if (root == NULL)
return;
//std::string steamIds;
- node = json_get(root, "friends");
+ JSONNODE *node = json_get(root, "friends");
JSONNODE *nroot = json_as_array(node);
if (nroot != NULL)
{
for (size_t i = 0; i < json_size(nroot); i++)
{
- child = json_at(nroot, i);
+ JSONNODE *child = json_at(nroot, i);
if (child == NULL)
break;
@@ -291,8 +287,6 @@ void CSteamProto::OnGotBlockList(const NETLIBHTTPREQUEST *response, void *arg) else continue;
}
}
-
- json_delete(root);
}
void CSteamProto::OnGotUserSummaries(const NETLIBHTTPREQUEST *response, void *arg)
@@ -300,15 +294,17 @@ void CSteamProto::OnGotUserSummaries(const NETLIBHTTPREQUEST *response, void *ar if (response == NULL)
return;
- JSONNODE *root = json_parse(response->pData), *node, *item;
-
- node = json_get(root, "players");
+ JSONROOT root(response->pData);
+ if (root == NULL)
+ return;
+
+ JSONNODE *node = json_get(root, "players");
JSONNODE *nroot = json_as_array(node);
if (nroot != NULL)
{
for (size_t i = 0; i < json_size(nroot); i++)
{
- item = json_at(nroot, i);
+ JSONNODE *item = json_at(nroot, i);
if (item == NULL)
break;
@@ -322,8 +318,6 @@ void CSteamProto::OnGotUserSummaries(const NETLIBHTTPREQUEST *response, void *ar UpdateContact(hContact, item);
}
}
-
- json_delete(root);
}
void CSteamProto::OnGotAvatar(const NETLIBHTTPREQUEST *response, void *arg)
@@ -400,9 +394,11 @@ void CSteamProto::OnAuthRequested(const NETLIBHTTPREQUEST *response, void *arg) return;
}
- JSONNODE *root = json_parse(response->pData), *node;
+ JSONROOT root(response->pData);
+ if (root == NULL)
+ return;
- node = json_get(root, "players");
+ JSONNODE *node = json_get(root, "players");
JSONNODE *nroot = json_at(json_as_array(node), 0);
if (nroot != NULL)
{
@@ -448,8 +444,6 @@ void CSteamProto::OnAuthRequested(const NETLIBHTTPREQUEST *response, void *arg) AddDBEvent(hContact, EVENTTYPE_AUTHREQUEST, time(NULL), DBEF_UTF, cbBlob, pBlob);
}
-
- json_delete(root);
}
void CSteamProto::OnPendingApproved(const NETLIBHTTPREQUEST *response, void *arg)
@@ -460,16 +454,16 @@ void CSteamProto::OnPendingApproved(const NETLIBHTTPREQUEST *response, void *arg return;
}
- JSONNODE *root = json_parse(response->pData), *node;
+ JSONROOT root(response->pData);
+ if (root == NULL)
+ return;
- node = json_get(root, "success");
+ JSONNODE *node = json_get(root, "success");
if (json_as_int(node) == 0)
{
node = json_get(root, "error_text");
debugLogA("CSteamProto::OnPendingApproved: failed to approve pending from %s (%s)", ptrA((char*)arg), ptrA(mir_utf8encodeW(json_as_string(node))));
}
-
- json_delete(root);
}
void CSteamProto::OnPendingIgnoreded(const NETLIBHTTPREQUEST *response, void *arg)
@@ -480,16 +474,16 @@ void CSteamProto::OnPendingIgnoreded(const NETLIBHTTPREQUEST *response, void *ar return;
}
- JSONNODE *root = json_parse(response->pData), *node;
+ JSONROOT root(response->pData);
+ if (root == NULL)
+ return;
- node = json_get(root, "success");
+ JSONNODE *node = json_get(root, "success");
if (json_as_int(node) == 0)
{
node = json_get(root, "error_text");
debugLogA("CSteamProto::OnPendingApproved: failed to ignore pending from %s (%s)", ptrA((char*)arg), ptrA(mir_utf8encodeW(json_as_string(node))));
}
-
- json_delete(root);
}
void CSteamProto::OnSearchByIdEnded(const NETLIBHTTPREQUEST *response, void *arg)
@@ -501,11 +495,13 @@ void CSteamProto::OnSearchByIdEnded(const NETLIBHTTPREQUEST *response, void *arg return;
}
- JSONNODE *root = json_parse(response->pData), *node;
+ JSONROOT root(response->pData);
+ if (root == NULL)
+ return;
- node = json_get(root, "players");
- root = json_at(json_as_array(node), 0);
- if (root != NULL)
+ JSONNODE *node = json_get(root, "players");
+ JSONNODE *nroot = json_at(json_as_array(node), 0);
+ if (nroot != NULL)
{
STEAM_SEARCH_RESULT ssr = { 0 };
ssr.hdr.cbSize = sizeof(STEAM_SEARCH_RESULT);
@@ -513,10 +509,10 @@ void CSteamProto::OnSearchByIdEnded(const NETLIBHTTPREQUEST *response, void *arg ssr.hdr.id = (wchar_t*)arg;
- node = json_get(root, "personaname");
+ node = json_get(nroot, "personaname");
ssr.hdr.nick = mir_wstrdup(json_as_string(node));
- node = json_get(root, "realname");
+ node = json_get(nroot, "realname");
if (node != NULL)
{
std::wstring realname = json_as_string(node);
@@ -534,7 +530,7 @@ void CSteamProto::OnSearchByIdEnded(const NETLIBHTTPREQUEST *response, void *arg }
//ssr.contact = contact;
- ssr.data = json_copy(root);
+ ssr.data = json_copy(nroot);
ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)STEAM_SEARCH_BYID, (LPARAM)&ssr);
ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)STEAM_SEARCH_BYID, 0);
diff --git a/protocols/Steam/src/steam_messages.cpp b/protocols/Steam/src/steam_messages.cpp index 9cd76f3b0f..7e6e07c315 100644 --- a/protocols/Steam/src/steam_messages.cpp +++ b/protocols/Steam/src/steam_messages.cpp @@ -23,16 +23,13 @@ void CSteamProto::OnMessageSent(const NETLIBHTTPREQUEST *response, void *arg) if (response != NULL && response->resultCode == HTTP_STATUS_OK)
{
- JSONNODE *root = json_parse(response->pData), *node;
-
- node = json_get(root, "error");
+ JSONROOT root(response->pData);
+ JSONNODE *node = json_get(root, "error");
ptrA error(mir_utf8encodeW(json_as_string(node)));
if (lstrcmpiA(error, "OK") == 0)
result = true;
else
debugLogA("CSteamProto::OnMessageSent: failed to send message for %s (%s)", steamId, error);
-
- json_delete(root);
}
else
debugLogA("CSteamProto::OnMessageSent: failed to send message for %s", steamId);
diff --git a/protocols/Steam/src/steam_pooling.cpp b/protocols/Steam/src/steam_pooling.cpp index 2c07872fe3..78ac23e53c 100644 --- a/protocols/Steam/src/steam_pooling.cpp +++ b/protocols/Steam/src/steam_pooling.cpp @@ -188,8 +188,8 @@ void CSteamProto::PollingThread(void*) if (response == NULL || response->resultCode != HTTP_STATUS_OK)
return;
- JSONNODE *root = json_parse(response->pData), *node;
- node = json_get(root, "error");
+ JSONROOT root(response->pData);
+ JSONNODE *node = json_get(root, "error");
ptrW error(json_as_string(node));
if (!lstrcmpi(error, L"OK"))
@@ -207,7 +207,6 @@ void CSteamProto::PollingThread(void*) }
else if (!lstrcmpi(error, L"Timeout"))
{
- json_delete(root);
continue;
}
/*else if (!lstrcmpi(error, L"Not Logged On")) // 'else' below will handle this error, we don't need this particular check right now
@@ -234,7 +233,6 @@ void CSteamProto::PollingThread(void*) breaked = true;
}
- json_delete(root);
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)response);
}
|