]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
fix null pointer auto of memory kds net
authorBastian Dehn <hhaalo@arcor.de>
Sat, 11 Oct 2025 08:38:01 +0000 (10:38 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sat, 11 Oct 2025 08:51:56 +0000 (10:51 +0200)
src/kds_s2000w_net.c

index eb2225c7bfe0b550072253ec53db5c7f30812cf0..6a184d9eae1b51335fce4a8cd6c5eba3fddad0e1 100644 (file)
@@ -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;