aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Dessaux2019-09-12 18:00:06 +0200
committerJulien Dessaux2019-09-12 18:00:06 +0200
commitd43beb750651f75f9dcb5f18123008ba9e93352f (patch)
treeaa389c2d1470bcaf902c2e8aa66ec32c9b92e3aa
parentHave the subscription struct hold the unread counters (diff)
downloadrocket-cli-client-d43beb750651f75f9dcb5f18123008ba9e93352f.tar.gz
rocket-cli-client-d43beb750651f75f9dcb5f18123008ba9e93352f.tar.bz2
rocket-cli-client-d43beb750651f75f9dcb5f18123008ba9e93352f.zip
Fixed code flow with memory free
-rw-r--r--close_direct_conversations/main.c3
-rw-r--r--common/http.c3
2 files changed, 4 insertions, 2 deletions
diff --git a/close_direct_conversations/main.c b/close_direct_conversations/main.c
index 9c723f9..122420d 100644
--- a/close_direct_conversations/main.c
+++ b/close_direct_conversations/main.c
@@ -48,12 +48,13 @@ int main(void)
}
restapi_im_close(buff);
free(buff);
+
+ restapi_logout();
}
} else {
printf("Couldn't init rest api.\n");
}
- restapi_logout();
config_clean();
common_cli_free();
diff --git a/common/http.c b/common/http.c
index 0a87b6a..9ad091d 100644
--- a/common/http.c
+++ b/common/http.c
@@ -90,7 +90,6 @@ const char * http_perform(const char* path, const char* postfields)
strcpy(url, weburl);
strcpy(url + weburl_len, path);
curl_easy_setopt(curl, CURLOPT_URL, url);
- free(url);
if (postfields != NULL)
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postfields);
if (headers != NULL)
@@ -98,8 +97,10 @@ const char * http_perform(const char* path, const char* postfields)
CURLcode res = curl_easy_perform(curl);
if(res != CURLE_OK) {
fprintf(stderr, "HTTP get to %s failed: %s\n", url, curl_easy_strerror(res));
+ free(url);
return NULL;
}
+ free(url);
return buffer;
}