aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordequis <dx@dxzone.com.ar>2015-10-08 04:48:06 -0300
committerdequis <dx@dxzone.com.ar>2015-10-08 23:41:01 -0300
commitbbff22d5c2f3a7cef28bd57c7a73379b0c5d2623 (patch)
treef2141e656c810378a80e13db510eaded4a3b346f
parentc4e61db186c2e0916e43a1ffc85afe5997aaf345 (diff)
twitter: Fix some nitpicky issues reported by coverity
Mostly minor rare leaks that happen in error conditions, and one dereference before null check in twitter_logout (the null check is probably the wrong one there, but it doesn't hurt to keep it)
-rw-r--r--protocols/twitter/twitter.c12
-rw-r--r--protocols/twitter/twitter_http.c6
-rw-r--r--protocols/twitter/twitter_lib.c27
3 files changed, 24 insertions, 21 deletions
diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c
index b619b1e5..a8103cca 100644
--- a/protocols/twitter/twitter.c
+++ b/protocols/twitter/twitter.c
@@ -677,14 +677,14 @@ static void twitter_logout(struct im_connection *ic)
// Set the status to logged out.
ic->flags &= ~OPT_LOGGED_IN;
- // Remove the main_loop function from the function queue.
- b_event_remove(td->main_loop_id);
+ if (td) {
+ // Remove the main_loop function from the function queue.
+ b_event_remove(td->main_loop_id);
- if (td->timeline_gc) {
- imcb_chat_free(td->timeline_gc);
- }
+ if (td->timeline_gc) {
+ imcb_chat_free(td->timeline_gc);
+ }
- if (td) {
if (td->filter_update_id > 0) {
b_event_remove(td->filter_update_id);
}
diff --git a/protocols/twitter/twitter_http.c b/protocols/twitter/twitter_http.c
index 2632f333..c06cac39 100644
--- a/protocols/twitter/twitter_http.c
+++ b/protocols/twitter/twitter_http.c
@@ -52,7 +52,7 @@ struct http_request *twitter_http(struct im_connection *ic, char *url_string, ht
struct twitter_data *td = ic->proto_data;
char *tmp;
GString *request = g_string_new("");
- void *ret;
+ void *ret = NULL;
char *url_arguments;
url_t *base_url = NULL;
@@ -71,8 +71,7 @@ struct http_request *twitter_http(struct im_connection *ic, char *url_string, ht
if (strstr(url_string, "://")) {
base_url = g_new0(url_t, 1);
if (!url_set(base_url, url_string)) {
- g_free(base_url);
- return NULL;
+ goto error;
}
}
@@ -131,6 +130,7 @@ struct http_request *twitter_http(struct im_connection *ic, char *url_string, ht
ret = http_dorequest(td->url_host, td->url_port, td->url_ssl, request->str, func, data);
}
+error:
g_free(url_arguments);
g_string_free(request, TRUE);
g_free(base_url);
diff --git a/protocols/twitter/twitter_lib.c b/protocols/twitter/twitter_lib.c
index 40adb992..80747015 100644
--- a/protocols/twitter/twitter_lib.c
+++ b/protocols/twitter/twitter_lib.c
@@ -311,14 +311,14 @@ static void twitter_http_get_friends_ids(struct http_request *req)
td = ic->proto_data;
- txl = g_new0(struct twitter_xml_list, 1);
- txl->list = td->follow_ids;
-
// Parse the data.
if (!(parsed = twitter_parse_response(ic, req))) {
return;
}
+ txl = g_new0(struct twitter_xml_list, 1);
+ txl->list = td->follow_ids;
+
twitter_xt_get_friends_id_list(parsed, txl);
json_value_free(parsed);
@@ -387,13 +387,14 @@ static void twitter_http_get_users_lookup(struct http_request *req)
return;
}
- txl = g_new0(struct twitter_xml_list, 1);
- txl->list = NULL;
-
// Get the user list from the parsed xml feed.
if (!(parsed = twitter_parse_response(ic, req))) {
return;
}
+
+ txl = g_new0(struct twitter_xml_list, 1);
+ txl->list = NULL;
+
twitter_xt_get_users(parsed, txl);
json_value_free(parsed);
@@ -1384,13 +1385,14 @@ static void twitter_http_get_home_timeline(struct http_request *req)
td = ic->proto_data;
- txl = g_new0(struct twitter_xml_list, 1);
- txl->list = NULL;
-
// The root <statuses> node should hold the list of statuses <status>
if (!(parsed = twitter_parse_response(ic, req))) {
goto end;
}
+
+ txl = g_new0(struct twitter_xml_list, 1);
+ txl->list = NULL;
+
twitter_xt_get_status_list(ic, parsed, txl);
json_value_free(parsed);
@@ -1423,13 +1425,14 @@ static void twitter_http_get_mentions(struct http_request *req)
td = ic->proto_data;
- txl = g_new0(struct twitter_xml_list, 1);
- txl->list = NULL;
-
// The root <statuses> node should hold the list of statuses <status>
if (!(parsed = twitter_parse_response(ic, req))) {
goto end;
}
+
+ txl = g_new0(struct twitter_xml_list, 1);
+ txl->list = NULL;
+
twitter_xt_get_status_list(ic, parsed, txl);
json_value_free(parsed);