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/idevicebackup.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'tools/idevicebackup.c') diff --git a/tools/idevicebackup.c b/tools/idevicebackup.c index 95c5694..8f5362c 100644 --- a/tools/idevicebackup.c +++ b/tools/idevicebackup.c @@ -755,7 +755,7 @@ static void do_post_notification(const char *notification) } lockdownd_start_service(client, NP_SERVICE_NAME, &service); - if (service->port) { + if (service && service->port) { np_client_new(device, service, &np); if (np) { np_post_notification(np, notification); @@ -937,7 +937,7 @@ int main(int argc, char *argv[]) /* start notification_proxy */ np_client_t np = NULL; ret = lockdownd_start_service(client, 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] = { @@ -952,11 +952,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 */ @@ -975,7 +970,7 @@ int main(int argc, char *argv[]) /* start mobilebackup service and retrieve port */ ret = lockdownd_start_service(client, MOBILEBACKUP_SERVICE_NAME, &service); - if ((ret == LOCKDOWN_E_SUCCESS) && service->port) { + if ((ret == LOCKDOWN_E_SUCCESS) && service && service->port) { printf("Started \"%s\" service on port %d.\n", MOBILEBACKUP_SERVICE_NAME, service->port); mobilebackup_client_new(device, service, &mobilebackup); -- cgit v1.1-32-gdbae