diff --git a/lib/usb_relay_device.h b/lib/usb_relay_device.h index 19a62df..8c08e26 100644 --- a/lib/usb_relay_device.h +++ b/lib/usb_relay_device.h @@ -70,7 +70,7 @@ It should be called at the end of execution to avoid memory leaks. int USBRL_API usb_relay_exit(void); /** Enumerate the USB Relay Devices. -@return Pointer to list of usb_relay_device_info +@return Pointer to list of usb_relay_device_info, NULL if unsuccessful. Caller should free it with usb_relay_device_free_enumerate */ pusb_relay_device_info_t USBRL_API usb_relay_device_enumerate(void); diff --git a/lib/usb_relay_lib.c b/lib/usb_relay_lib.c index 8758460..f7869f8 100644 --- a/lib/usb_relay_lib.c +++ b/lib/usb_relay_lib.c @@ -385,6 +385,9 @@ pusb_relay_device_info_t USBRL_API usb_relay_device_enumerate(void) (void*)&ectx, enumfunc); + if ( ret != 0 ) + return NULL; + return (pusb_relay_device_info_t)ectx.head; }