diff --git a/http_curl.h b/http_curl.h index da9a2b0..95862c9 100644 --- a/http_curl.h +++ b/http_curl.h @@ -68,7 +68,7 @@ char *curl_post(const char *url, const char *data) { curl_easy_setopt(curl, CURLOPT_URL, url); headers = curl_slist_append(headers, "Content-Type: application/json"); char bearer_header[1337]; - sprintf(bearer_header, "Authorization: Bearer %s", resolve_api_key()); + snprintf(bearer_header, sizeof(bearer_header), "Authorization: Bearer %s", resolve_api_key()); headers = curl_slist_append(headers, bearer_header); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data); @@ -84,6 +84,7 @@ char *curl_post(const char *url, const char *data) { curl_easy_cleanup(curl); return response.data; } + free(response.data); return NULL; } @@ -101,7 +102,7 @@ char *curl_get(const char *url) { curl_easy_setopt(curl, CURLOPT_URL, url); headers = curl_slist_append(headers, "Content-Type: application/json"); char bearer_header[1337]; - sprintf(bearer_header, "Authorization: Bearer %s", resolve_api_key()); + snprintf(bearer_header, sizeof(bearer_header), "Authorization: Bearer %s", resolve_api_key()); headers = curl_slist_append(headers, bearer_header); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback); @@ -112,8 +113,11 @@ char *curl_get(const char *url) { } curl_slist_free_all(headers); curl_easy_cleanup(curl); + } else { + free(response.data); + return NULL; } return response.data; } -#endif +#endif \ No newline at end of file diff --git a/rpylib.so b/rpylib.so index 3420745..91c3308 100755 Binary files a/rpylib.so and b/rpylib.so differ