summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/iphone.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/iphone.c b/src/iphone.c
index 6eb56f7..c2a79bb 100644
--- a/src/iphone.c
+++ b/src/iphone.c
@@ -230,13 +230,15 @@ iphone_error_t iphone_free_device(iphone_device_t device)
unsigned char buf[512];
// read final package(s)
- do {
- bytes = usb_bulk_read(device->device, BULKIN, (void *) &buf, 512, 800);
- if (bytes > 0) {
- log_debug_msg("iphone_free_device: final read returned\n");
- log_debug_buffer(buf, bytes);
- }
- } while (bytes > 0);
+ if (device->device != NULL) {
+ do {
+ bytes = usb_bulk_read(device->device, BULKIN, (void *) &buf, 512, 800);
+ if (bytes > 0) {
+ log_debug_msg("iphone_free_device: final read returned\n");
+ log_debug_buffer(buf, bytes);
+ }
+ } while (bytes > 0);
+ }
if (device->buffer) {
free(device->buffer);