X-Git-Url: https://git.toastfreeware.priv.at/gregoa/bti.git/blobdiff_plain/bfe6897366a85b1d76be9528e41b5ee8bb3a570c..c1254c229cf3c239a406cb063a13b17961da15b0:/bti.c diff --git a/bti.c b/bti.c index 6f77ddc..9a6fae2 100644 --- a/bti.c +++ b/bti.c @@ -557,8 +557,10 @@ static int send_request(struct session *session) curl_buf->session = session; curl = curl_init(); - if (!curl) + if (!curl) { + bti_curl_buffer_free(curl_buf); return -EINVAL; + } if (!session->hosturl) session->hosturl = strdup(twitter_host); @@ -658,6 +660,10 @@ static int send_request(struct session *session) if (res) { fprintf(stderr, "error(%d) trying to " "perform operation\n", res); + curl_easy_cleanup(curl); + if (session->action == ACTION_UPDATE) + curl_formfree(formpost); + bti_curl_buffer_free(curl_buf); return -EINVAL; } @@ -665,19 +671,32 @@ static int send_request(struct session *session) curl_buf->length, "response.xml", NULL, XML_PARSE_NOERROR); - if (doc == NULL) + if (doc == NULL) { + curl_easy_cleanup(curl); + if (session->action == ACTION_UPDATE) + curl_formfree(formpost); + bti_curl_buffer_free(curl_buf); return -EINVAL; + } current = xmlDocGetRootElement(doc); if (current == NULL) { fprintf(stderr, "empty document\n"); xmlFreeDoc(doc); + curl_easy_cleanup(curl); + if (session->action == ACTION_UPDATE) + curl_formfree(formpost); + bti_curl_buffer_free(curl_buf); return -EINVAL; } if (xmlStrcmp(current->name, (const xmlChar *)"status")) { fprintf(stderr, "unexpected document type\n"); xmlFreeDoc(doc); + curl_easy_cleanup(curl); + if (session->action == ACTION_UPDATE) + curl_formfree(formpost); + bti_curl_buffer_free(curl_buf); return -EINVAL; }