summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2020-01-25 18:30:12 +0100
committerMarcus Meissner <marcus@jet.franken.de>2020-01-25 18:30:12 +0100
commit9590742c1c8a4f9e50d7daff19cb1385559ce8dc (patch)
tree4063aa2edcc894ae31fc12c5f2b2cfadf1163dad
parent8a06cb3f5a53a212ef79a877c393088866f7ea15 (diff)
downloadlibgphoto2-9590742c1c8a4f9e50d7daff19cb1385559ce8dc.tar.gz
avoid endless loops when device goes away (AFL)
-rw-r--r--camlibs/clicksmart310/clicksmart.c10
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);