From 8d5a0dcaf45c5a2d70ab08e7a63dc1c8d26d843b Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Sat, 11 Oct 2025 10:38:01 +0200 Subject: [PATCH] fix null pointer auto of memory kds net --- src/kds_s2000w_net.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/kds_s2000w_net.c b/src/kds_s2000w_net.c index eb2225c..6a184d9 100644 --- a/src/kds_s2000w_net.c +++ b/src/kds_s2000w_net.c @@ -43,10 +43,16 @@ SANE_Status sane_kds_s2000w_net_get_devices(SANE_Device*** device_list, if (local_only) return SANE_STATUS_NO_MEM; - if (device_info_ptr == NULL) { - device_info_ptr = malloc(sizeof(SANE_Device*) * 2); - device_info_ptr[0] = malloc(sizeof(SANE_Device)); - } + if (device_info_ptr != NULL) + return SANE_STATUS_GOOD; + + device_info_ptr = malloc(sizeof(SANE_Device*) * 2); + if (device_info_ptr == NULL) + return SANE_STATUS_NO_MEM; + + device_info_ptr[0] = malloc(sizeof(SANE_Device)); + if (device_info_ptr[0] == NULL) + return SANE_STATUS_NO_MEM; device_info_ptr[0]->name = NAME; device_info_ptr[0]->vendor = VENDOR; -- 2.47.3