summaryrefslogtreecommitdiffstats
path: root/tools/idevicebackup.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2013-03-14 03:09:14 +0100
committerGravatar Nikias Bassen2013-03-14 03:09:14 +0100
commit4222bc1b880d6535462e3b5ba5431809a3c5fddc (patch)
treeb664bbdfe96d162930b2719ec920cd149684b0ed /tools/idevicebackup.c
parent23abc8303b8cad9251cd4ea4b5fa5af28e5f0b24 (diff)
downloadlibimobiledevice-4222bc1b880d6535462e3b5ba5431809a3c5fddc.tar.gz
libimobiledevice-4222bc1b880d6535462e3b5ba5431809a3c5fddc.tar.bz2
global: make sure to check service before checking service->port to prevent crashes
Diffstat (limited to 'tools/idevicebackup.c')
-rw-r--r--tools/idevicebackup.c11
1 files changed, 3 insertions, 8 deletions
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);