]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
fix allocation issue kds converter test
authorBastian Dehn <hhaalo@arcor.de>
Sat, 11 Oct 2025 12:09:33 +0000 (14:09 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sat, 11 Oct 2025 12:09:33 +0000 (14:09 +0200)
tests/kds_s2000w_image_converter_tests.c

index cbdd9c90550f65fda372022880a9dee67b91b5d1..32032690b724d9d6cd6eac09f22967b16f78507d 100644 (file)
 void get_metadata_from_image_test()
 {
        blobdata* image = malloc(sizeof(blobdata));
+       if (image == NULL)
+               return;
        image->data = malloc(sizeof(char) * 17);
+       if (image->data == NULL) {
+               free(image);
+               image = NULL;
+               return;
+       }
        image->size = 17;
        char* image_data = (char*) image->data;
        image_data[0] = 0x50;
@@ -29,6 +36,13 @@ void get_metadata_from_image_test()
                image_data[i] = (char) 0xff;
        }
        image_metadata* mdata = malloc(sizeof(image_metadata));
+       if (mdata == NULL) {
+               free(image->data);
+               image->data = NULL;
+               free(image);
+               image = NULL;
+               return;
+       }
        mdata->width = 0;
        mdata->height = 0;
        mdata->depth = 0;