]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
fix: invalid free wrong option
authorBastian Dehn <hhaalo@arcor.de>
Sat, 25 Oct 2025 09:26:12 +0000 (11:26 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sat, 25 Oct 2025 09:26:41 +0000 (11:26 +0200)
src/kds_s2000w_client.c

index 323fee52f0a06756d352dd87defa03369faac059..e7333bc59304c866f82d5e0ebca940a8a52e94d9 100644 (file)
@@ -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, &param->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, &param->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);