mirror of
https://github.com/simon987/sist2.git
synced 2025-12-16 00:39:04 +00:00
Fix some memory leaks
This commit is contained in:
@@ -213,8 +213,10 @@ cJSON *elastic_get_document(const char *uuid_str) {
|
||||
snprintf(url, 4096, "%s/sist2/_doc/%s", WebCtx.es_url, uuid_str);
|
||||
|
||||
response_t *r = web_get(url);
|
||||
cJSON *json = NULL;
|
||||
if (r->status_code == 200) {
|
||||
return cJSON_Parse(r->body);
|
||||
json = cJSON_Parse(r->body);
|
||||
}
|
||||
return NULL;
|
||||
free_response(r);
|
||||
return json;
|
||||
}
|
||||
|
||||
@@ -49,18 +49,19 @@ response_t *web_post(const char *url, const char *data, const char *header) {
|
||||
curl_easy_setopt(curl, CURLOPT_POST, 1);
|
||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, "sist2");
|
||||
|
||||
struct curl_slist *headers = NULL;
|
||||
if (header != NULL) {
|
||||
struct curl_slist *headers = NULL;
|
||||
headers = curl_slist_append(headers, header);
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
|
||||
|
||||
int r1 = curl_easy_perform(curl);
|
||||
curl_easy_perform(curl);
|
||||
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &resp->status_code);
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_slist_free_all(headers);
|
||||
|
||||
resp->body = buffer.buf;
|
||||
resp->size = buffer.cur;
|
||||
|
||||
Reference in New Issue
Block a user