summaryrefslogtreecommitdiffstats
path: root/iphone.c
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2009-04-13 05:37:35 +0200
committerGravatar Nikias Bassen2009-04-13 05:37:35 +0200
commit322a3e80835aacc2abaa802545143ebde69d21da (patch)
tree5a5f6d03eec2767442f1c896de2ebe205539e334 /iphone.c
parente1751b8c02822da3881b41a8e07a36665a163130 (diff)
downloadusbmuxd-322a3e80835aacc2abaa802545143ebde69d21da.tar.gz
usbmuxd-322a3e80835aacc2abaa802545143ebde69d21da.tar.bz2
Check for set usb_device in iphone_free_device to avoid libusb segfault
Signed-off-by: Nikias Bassen <nikias@gmx.li>
Diffstat (limited to 'iphone.c')
-rw-r--r--iphone.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/iphone.c b/iphone.c
index 5cceb95..6be85e6 100644
--- a/iphone.c
+++ b/iphone.c
@@ -427,9 +427,11 @@ iphone_error_t iphone_free_device(iphone_device_t device)
return IPHONE_E_INVALID_ARG;
iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR;
- do {
- bytes = usb_bulk_read(device->device, BULKIN, buf, 512, 800);
- } while (bytes > 0);
+ if (device->device) {
+ do {
+ bytes = usb_bulk_read(device->device, BULKIN, buf, 512, 800);
+ } while (bytes > 0);
+ }
if (device->buffer) {
free(device->buffer);