From ebefa164aeb716d3323be4c19daa046500c1c4a4 Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Sat, 25 Oct 2025 11:26:12 +0200 Subject: [PATCH] fix: invalid free wrong option --- src/kds_s2000w_client.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/kds_s2000w_client.c b/src/kds_s2000w_client.c index 323fee5..e7333bc 100644 --- a/src/kds_s2000w_client.c +++ b/src/kds_s2000w_client.c @@ -57,6 +57,9 @@ void _kds_s2000w_client_set_verbose(CURL* curl) size_t _kds_s2000w_client_write_callback(const char* ptr, size_t size, size_t nmemb, void* data) { + if (data == NULL) + return 0; + response_t* resp = (response_t*) data; char* tmp_resp = realloc(resp->data, resp->size + size * nmemb); @@ -337,6 +340,7 @@ void kds_s2000w_client_close_session(int64_t sessionid) curl_url_get(param->url_handler, CURLUPART_URL, ¶m->url, 0); curl_easy_setopt(param->curl, CURLOPT_URL, param->url); curl_easy_setopt(param->curl, CURLOPT_CUSTOMREQUEST, HTTP_DELETE); + curl_easy_setopt(param->curl, CURLOPT_WRITEDATA, NULL); CURLcode result = curl_easy_perform(param->curl); _kds_s2000w_client_print_error_result(result, param->errbuf); @@ -417,6 +421,7 @@ uint8_t kds_s2000w_client_start_scan(int64_t sessionid) curl_easy_setopt(param->curl, CURLOPT_URL, param->url); curl_easy_setopt(param->curl, CURLOPT_POST, 1L); curl_easy_setopt(param->curl, CURLOPT_POSTFIELDSIZE, 0L); + curl_easy_setopt(param->curl, CURLOPT_WRITEDATA, NULL); CURLcode result = curl_easy_perform(param->curl); _kds_s2000w_client_print_error_status(param->curl); @@ -442,6 +447,7 @@ uint8_t kds_s2000w_client_stop_scan(int64_t sessionid) curl_easy_setopt(param->curl, CURLOPT_URL, param->url); curl_easy_setopt(param->curl, CURLOPT_POST, 1L); curl_easy_setopt(param->curl, CURLOPT_POSTFIELDSIZE, 0L); + curl_easy_setopt(param->curl, CURLOPT_WRITEDATA, NULL); CURLcode result = curl_easy_perform(param->curl); _kds_s2000w_client_print_error_status(param->curl); @@ -496,6 +502,7 @@ uint8_t kds_s2000w_client_delete_image(int64_t sessionid, uint8_t img_number) curl_url_get(param->url_handler, CURLUPART_URL, ¶m->url, 0); curl_easy_setopt(param->curl, CURLOPT_URL, param->url); curl_easy_setopt(param->curl, CURLOPT_CUSTOMREQUEST, HTTP_DELETE); + curl_easy_setopt(param->curl, CURLOPT_WRITEDATA, NULL); CURLcode result = curl_easy_perform(param->curl); _kds_s2000w_client_print_error_status(param->curl); @@ -551,6 +558,7 @@ uint8_t kds_s2000w_client_set_option(int64_t sessionid, response_t* resp) curl_easy_setopt(param->curl, CURLOPT_POSTFIELDS, resp->data); curl_easy_setopt(param->curl, CURLOPT_POSTFIELDSIZE, resp->size); curl_easy_setopt(param->curl, CURLOPT_CUSTOMREQUEST, HTTP_PUT); + curl_easy_setopt(param->curl, CURLOPT_WRITEDATA, NULL); CURLcode result = curl_easy_perform(param->curl); curl_easy_getinfo(param->curl, CURLINFO_RESPONSE_CODE, &resp->code); -- 2.47.3