Fix crash when no devices connected
diff --git a/src/libmtp.c b/src/libmtp.c
index ccda8f3..ee4cfcb 100644
--- a/src/libmtp.c
+++ b/src/libmtp.c
@@ -607,22 +607,21 @@
/* Specific Errors or Messages that connect_mtp_devices should return */
case LIBMTP_ERROR_N0_DEVICE_ATTACHED:
fprintf(stderr, "LIBMTP_Get_First_Device: No Devices Attached\n");
- break;
+ return NULL;
case LIBMTP_ERROR_CONNECTING:
fprintf(stderr, "LIBMTP_Get_First_Device: Error Connecting\n");
- break;
+ return NULL;
case LIBMTP_ERROR_MEMORY_ALLOCATION:
fprintf(stderr, "LIBMTP_Get_First_Device: Memory Alloc Error\n");
- break;
+ return NULL;
/* Unknown general errors - This should never execute */
case LIBMTP_ERROR_GENERAL:
default:
fprintf(stderr, "LIBMTP_Get_First_Device: Unknown Connection Error\n");
-
- break;
+ return NULL;
/* Successfully connect at least one device, so continue */
case LIBMTP_ERROR_NONE: