From 4222bc1b880d6535462e3b5ba5431809a3c5fddc Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Thu, 14 Mar 2013 03:09:14 +0100 Subject: global: make sure to check service before checking service->port to prevent crashes --- tools/idevicebackup2.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'tools/idevicebackup2.c') diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c index 0353c9b..d70a7ae 100644 --- a/tools/idevicebackup2.c +++ b/tools/idevicebackup2.c @@ -489,7 +489,7 @@ static void do_post_notification(idevice_t device, const char *notification) } lockdownd_start_service(lockdown, NP_SERVICE_NAME, &service); - if (service->port) { + if (service && service->port) { np_client_new(device, service, &np); if (np) { np_post_notification(np, notification); @@ -1557,7 +1557,7 @@ int main(int argc, char *argv[]) /* start notification_proxy */ np_client_t np = NULL; ret = lockdownd_start_service(lockdown, NP_SERVICE_NAME, &service); - if ((ret == LOCKDOWN_E_SUCCESS) && service->port) { + if ((ret == LOCKDOWN_E_SUCCESS) && service && service->port) { np_client_new(device, service, &np); np_set_notify_callback(np, notify_cb, NULL); const char *noties[5] = { @@ -1572,11 +1572,6 @@ int main(int argc, char *argv[]) printf("ERROR: Could not start service %s.\n", NP_SERVICE_NAME); } - if (service) { - lockdownd_service_descriptor_free(service); - service = NULL; - } - afc_client_t afc = NULL; if (cmd == CMD_BACKUP) { /* start AFC, we need this for the lock file */ @@ -1596,7 +1591,7 @@ int main(int argc, char *argv[]) /* start mobilebackup service and retrieve port */ mobilebackup2_client_t mobilebackup2 = NULL; ret = lockdownd_start_service(lockdown, MOBILEBACKUP2_SERVICE_NAME, &service); - if ((ret == LOCKDOWN_E_SUCCESS) && service->port) { + if ((ret == LOCKDOWN_E_SUCCESS) && service && service->port) { PRINT_VERBOSE(1, "Started \"%s\" service on port %d.\n", MOBILEBACKUP2_SERVICE_NAME, service->port); mobilebackup2_client_new(device, service, &mobilebackup2); -- cgit v1.1-32-gdbae