diff options
author | Robert Pösel <robyer@seznam.cz> | 2014-08-11 13:52:39 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2014-08-11 13:52:39 +0000 |
commit | e6b2c1aafe3e877e3a6a90df006887d0b5f59f3d (patch) | |
tree | 09f6f8c440f9df9fdeec116ab69f1b245b5ef5e9 /protocols/FacebookRM/src/contacts.cpp | |
parent | d3e19377a2898c86499b31ca2ea85f8fce643438 (diff) |
Facebook: Fix various ptrA issues (potential crashes)
git-svn-id: http://svn.miranda-ng.org/main/trunk@10152 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/src/contacts.cpp')
-rw-r--r-- | protocols/FacebookRM/src/contacts.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp index ed8b3cdabe..7905007485 100644 --- a/protocols/FacebookRM/src/contacts.cpp +++ b/protocols/FacebookRM/src/contacts.cpp @@ -109,16 +109,14 @@ MCONTACT FacebookProto::ContactIDToHContact(std::string user_id) std::string FacebookProto::ThreadIDToContactID(std::string thread_id) { - std::string user_id; - for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { if (!IsMyContact(hContact)) continue; ptrA tid(getStringA(hContact, FACEBOOK_KEY_TID)); if (tid && !strcmp(tid, thread_id.c_str())) { - user_id = ptrA( getStringA(hContact, FACEBOOK_KEY_ID)); - return user_id; + ptrA id(getStringA(hContact, FACEBOOK_KEY_ID)); + return (id ? id : ""); } } @@ -132,8 +130,9 @@ std::string FacebookProto::ThreadIDToContactID(std::string thread_id) data += "&__a=1&__dyn=&__req=&ttstamp=0"; data += "&threads[thread_ids][0]=" + utils::url::encode(thread_id); + std::string user_id; http::response resp = facy.flap(REQUEST_THREAD_INFO, &data); - + if (resp.code == HTTP_CODE_OK) { CODE_BLOCK_TRY @@ -455,8 +454,12 @@ void FacebookProto::ApproveContactToServer(void *data) MCONTACT hContact = *(MCONTACT*)data; delete data; + ptrA id(ptrA(getStringA(hContact, FACEBOOK_KEY_ID))); + if (!id) + return; + std::string query = "action=confirm"; - query += "&id=" + std::string(ptrA(getStringA(hContact, FACEBOOK_KEY_ID))); + query += "&id=" + std::string(id); query += "&__user=" + facy.self_.user_id; query += "&fb_dtsg=" + facy.dtsg_; @@ -489,11 +492,13 @@ void FacebookProto::CancelFriendsRequest(void *data) MCONTACT hContact = *(MCONTACT*)data; delete data; + ptrA id(getStringA(hContact, FACEBOOK_KEY_ID)); + if (!id) + return; + std::string query = "confirmed=1"; query += "&fb_dtsg=" + facy.dtsg_; query += "&__user=" + facy.self_.user_id; - - ptrA id(getStringA(hContact, FACEBOOK_KEY_ID)); query += "&friend=" + std::string(id); // Cancel (our) friendship request @@ -525,8 +530,12 @@ void FacebookProto::IgnoreFriendshipRequest(void *data) MCONTACT hContact = *(MCONTACT*)data; delete data; + ptrA id(getStringA(hContact, FACEBOOK_KEY_ID)); + if (!id) + return; + std::string query = "action=reject"; - query += "&id=" + std::string(ptrA(getStringA(hContact, FACEBOOK_KEY_ID))); + query += "&id=" + std::string(id); query += "&__user=" + facy.self_.user_id; query += "&fb_dtsg=" + facy.dtsg_; |