From: Bastian Dehn Date: Sat, 11 Oct 2025 12:09:33 +0000 (+0200) Subject: fix allocation issue kds converter test X-Git-Tag: v1.1.10^2~3 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=5d2c2bc576fd713a8a14c883b0f1dfdfc3961531;p=sane-kds-s2000w-net.git fix allocation issue kds converter test --- diff --git a/tests/kds_s2000w_image_converter_tests.c b/tests/kds_s2000w_image_converter_tests.c index cbdd9c9..3203269 100644 --- a/tests/kds_s2000w_image_converter_tests.c +++ b/tests/kds_s2000w_image_converter_tests.c @@ -11,7 +11,14 @@ 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;