summaryrefslogtreecommitdiffstats
path: root/tools/idevicebackup2.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/idevicebackup2.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/idevicebackup2.c')
-rw-r--r--tools/idevicebackup2.c11
1 files changed, 3 insertions, 8 deletions
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);