]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
fix busy device handle null
authorBastian Dehn <hhaalo@arcor.de>
Wed, 15 Jan 2025 20:43:57 +0000 (21:43 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Wed, 15 Jan 2025 20:43:57 +0000 (21:43 +0100)
src/kds_s2000w_net.c

index dfdd869bc8b942faf3f538c61841892db3096fb8..43d0f1110d6c95a5c11a8c6f21bdcf9bfe5e3ca0 100644 (file)
@@ -59,12 +59,14 @@ SANE_Status _sane_kds_s2000w_net_open(SANE_String_Const devicename,
        if (h->state == NOTCONNECTED) {
                free_handler(h);
                h = NULL;
+               *handle = NULL;
                return SANE_STATUS_IO_ERROR;
        }
 
        if (h->state == BUSY) {
                free_handler(h);
                h = NULL;
+               *handle = NULL;
                return SANE_STATUS_DEVICE_BUSY;
        }
 
@@ -77,7 +79,7 @@ void _sane_kds_s2000w_net_close(SANE_Handle handle)
        debug_printf(ALL, "sane_kds_s2000w_net_close");
 
        handler* h = (handler*) handle;
-       if (h->state != OPENED)
+       if (h == NULL || h->state != OPENED)
                return;
 
        kds_s2000w_option_descriptor_free_option_descriptors();