diff options
author | Marcus Meissner <marcus@jet.franken.de> | 2020-01-25 18:30:12 +0100 |
---|---|---|
committer | Marcus Meissner <marcus@jet.franken.de> | 2020-01-25 18:30:12 +0100 |
commit | 9590742c1c8a4f9e50d7daff19cb1385559ce8dc (patch) | |
tree | 4063aa2edcc894ae31fc12c5f2b2cfadf1163dad | |
parent | 8a06cb3f5a53a212ef79a877c393088866f7ea15 (diff) | |
download | libgphoto2-9590742c1c8a4f9e50d7daff19cb1385559ce8dc.tar.gz |
avoid endless loops when device goes away (AFL)
-rw-r--r-- | camlibs/clicksmart310/clicksmart.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/camlibs/clicksmart310/clicksmart.c b/camlibs/clicksmart310/clicksmart.c index 9184c6cb4..f5586f930 100644 --- a/camlibs/clicksmart310/clicksmart.c +++ b/camlibs/clicksmart310/clicksmart.c @@ -53,8 +53,7 @@ CLICKSMART_READ (GPPort *port, int index, char *data) static int CLICKSMART_READ_STATUS (GPPort *port, char *data) { - gp_port_usb_msg_interface_read(port, 0, 0, CS_CH_READY, data, 1); - return GP_OK; + return gp_port_usb_msg_interface_read(port, 0, 0, CS_CH_READY, data, 1); } int clicksmart_init (GPPort *port, CameraPrivateLibrary *priv) @@ -86,8 +85,11 @@ int clicksmart_init (GPPort *port, CameraPrivateLibrary *priv) CLICKSMART_READ_STATUS (port, &c); gp_port_usb_msg_interface_write(port, 6, 0, 9, NULL, 0); - while (c != 1) - CLICKSMART_READ_STATUS (port, &c); + while (c != 1) { + if (GP_OK > CLICKSMART_READ_STATUS (port, &c)) { + return GP_ERROR_IO; + } + } buffer = malloc(0x200); if (!buffer) { free (temp_catalog); |