idevicepair: Fix udid being freed before printing error message containing udid
diff --git a/tools/idevicepair.c b/tools/idevicepair.c
index 77c46b7..be1f373 100644
--- a/tools/idevicepair.c
+++ b/tools/idevicepair.c
@@ -192,12 +192,13 @@
 
 	if (udid) {
 		ret = idevice_new(&device, udid);
-		free(udid);
-		udid = NULL;
 		if (ret != IDEVICE_E_SUCCESS) {
 			printf("No device found with udid %s, is it plugged in?\n", udid);
+			free(udid);
 			return EXIT_FAILURE;
 		}
+		free(udid);
+		udid = NULL;
 	} else {
 		ret = idevice_new(&device, NULL);
 		if (ret != IDEVICE_E_SUCCESS) {