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 --- dev/ideviceclient.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'dev/ideviceclient.c') diff --git a/dev/ideviceclient.c b/dev/ideviceclient.c index c8635d8..778f20e 100644 --- a/dev/ideviceclient.c +++ b/dev/ideviceclient.c @@ -49,7 +49,7 @@ static void perform_notification(idevice_t phone, lockdownd_client_t client, con np_client_t np; lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &service); - if (service->port) { + if (service && service->port) { printf("::::::::::::::: np was started ::::::::::::\n"); np_client_new(phone, service, &np); if (np) { @@ -109,15 +109,10 @@ int main(int argc, char *argv[]) lockdownd_start_service(client, "com.apple.afc", &service); - if (service->port) { + if (service && service->port) { afc_client_t afc = NULL; afc_client_new(phone, service, &afc); - if (service) { - lockdownd_service_descriptor_free(service); - service = NULL; - } - if (afc) { service->port = 0; service->ssl_enabled = 0; @@ -129,11 +124,6 @@ int main(int argc, char *argv[]) printf("ERROR: Notification proxy could not be started.\n"); } - if (service) { - lockdownd_service_descriptor_free(service); - service = NULL; - } - if (gnp) { const char *nspec[5] = { NP_SYNC_CANCEL_REQUEST, @@ -266,6 +256,9 @@ int main(int argc, char *argv[]) } afc_client_free(afc); + + lockdownd_service_descriptor_free(service); + service = NULL; } else { printf("Start service failure.\n"); } -- cgit v1.1-32-gdbae