diff options
author | Robert Pösel <robyer@seznam.cz> | 2014-12-20 19:10:47 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2014-12-20 19:10:47 +0000 |
commit | 58e5ea7bf98f8468f869522c89ffe961112bd98d (patch) | |
tree | 69cd89a853c4f315247e5724c6005a3d9e5d1e4e /protocols/FacebookRM/src/contacts.cpp | |
parent | 9f98d623506e7b7a86561152807526aeb2bb5be3 (diff) |
Facebook: Various code improvements (as reported by Coverity analyser); version bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@11546 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/src/contacts.cpp')
-rw-r--r-- | protocols/FacebookRM/src/contacts.cpp | 64 |
1 files changed, 27 insertions, 37 deletions
diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp index 6e7c281d17..a7196e5653 100644 --- a/protocols/FacebookRM/src/contacts.cpp +++ b/protocols/FacebookRM/src/contacts.cpp @@ -406,13 +406,11 @@ void FacebookProto::DeleteContactFromServer(void *data) if (data == NULL) return; - if (isOffline()) { - delete (std::string*)data; - return; - } + std::string id = *(std::string*)data; + delete (std::string*)data; - std::string id = (*(std::string*)data); - delete data; + if (isOffline()) + return; std::string query = "norefresh=true&unref=button_dropdown&confirmed=1&__a=1"; query += "&fb_dtsg=" + facy.dtsg_; @@ -457,13 +455,11 @@ void FacebookProto::AddContactToServer(void *data) if (data == NULL) return; - if (isOffline()) { - delete (std::string*)data; - return; - } + std::string id = *(std::string*)data; + delete (std::string*)data; - std::string id = (*(std::string*)data); - delete data; + if (isOffline()) + return; std::string query = "action=add_friend&how_found=profile_button&ref_param=ts&outgoing_id=&unwanted=&logging_location=&no_flyout_on_click=false&ego_log_data=&lsd="; query += "&fb_dtsg=" + facy.dtsg_; @@ -486,7 +482,6 @@ void FacebookProto::AddContactToServer(void *data) if (resp.code != HTTP_CODE_OK) facy.handle_error("AddContactToServer"); - } void FacebookProto::ApproveContactToServer(void *data) @@ -496,15 +491,13 @@ void FacebookProto::ApproveContactToServer(void *data) if (data == NULL) return; - if (isOffline()) { - delete (MCONTACT*)data; - return; - } - MCONTACT hContact = *(MCONTACT*)data; - delete data; + delete (MCONTACT*)data; + + if (isOffline()) + return; - ptrA id(ptrA(getStringA(hContact, FACEBOOK_KEY_ID))); + ptrA id(getStringA(hContact, FACEBOOK_KEY_ID)); if (!id) return; @@ -534,13 +527,11 @@ void FacebookProto::CancelFriendsRequest(void *data) if (data == NULL) return; - if (isOffline()) { - delete (MCONTACT*)data; - return; - } - MCONTACT hContact = *(MCONTACT*)data; - delete data; + delete (MCONTACT*)data; + + if (isOffline()) + return; ptrA id(getStringA(hContact, FACEBOOK_KEY_ID)); if (!id) @@ -572,13 +563,11 @@ void FacebookProto::IgnoreFriendshipRequest(void *data) if (data == NULL) return; - if (isOffline()) { - delete (MCONTACT*)data; - return; - } - MCONTACT hContact = *(MCONTACT*)data; - delete data; + delete (MCONTACT*)data; + + if (isOffline()) + return; ptrA id(getStringA(hContact, FACEBOOK_KEY_ID)); if (!id) @@ -614,15 +603,14 @@ void FacebookProto::SendPokeWorker(void *p) if (p == NULL) return; + std::string *id = (std::string*)p; + if (isOffline()) { - delete (std::string*)p; + delete id; return; } - std::string id = (*(std::string*)p); - delete p; - - std::string data = "poke_target=" + id; + std::string data = "poke_target=" + *id; data += "&do_confirm=0"; data += "&fb_dtsg=" + facy.dtsg_; data += "&__user=" + facy.self_.user_id; @@ -648,6 +636,8 @@ void FacebookProto::SendPokeWorker(void *p) } facy.handle_success("SendPokeWorker"); + + delete id; } |