]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
fix memory leak tests
authorBastian Dehn <hhaalo@arcor.de>
Wed, 13 Mar 2024 19:42:47 +0000 (20:42 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Wed, 13 Mar 2024 19:42:47 +0000 (20:42 +0100)
src/kds_s2000w_client.c
tests/kds_s2000w_net_tests.c

index 912a671d2cb9a49e50f0a11826457f7f9ea2639e..1221dbfeaba54ee71559e8e60322bd69d8f46a31 100644 (file)
@@ -57,6 +57,8 @@ void kds_s2000w_client_response_free(response* response)
        if (response == NULL)
                return;
 
+       free(response->data);
+       response->data = NULL;
        free(response);
        response = NULL;
 }
index d0d3fbb82182698daf666c2758e929e91f3086ac..c283842c4f6ca34ce63d7dd2acd9231fbc831d15 100644 (file)
@@ -8,7 +8,8 @@
 
 int kds_s2000w_client_get_option(int64_t sessionid, response* response)
 {
-       response->data = "{ \
+       response->data = realloc(response->data, 918);
+       const char* responsedata = "{ \
                \"Status\": { \
                        \"NumImagesScanned\": 0, \
                        \"NumImagesStored\": 0, \
@@ -42,7 +43,9 @@ int kds_s2000w_client_get_option(int64_t sessionid, response* response)
                        \"MaxDocumentLength\": 140, \
                        \"ScanSource\": \"DocumentFeeder\" \
                } \
-       }";
+       }\0";
+
+       memcpy(response->data, responsedata, 918);
 
        response->code = 200;
        response->size = sizeof(response->data);