From 3151cbe9969e1fb3b6fe2413b355b7f81ea62d2c Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Mon, 11 Jan 2010 13:28:03 +0100 Subject: Make sure we can pass NULL as lockdown label to disable sending one --- src/lockdown.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/lockdown.c b/src/lockdown.c index 5c51120..c78d691 100644 --- a/src/lockdown.c +++ b/src/lockdown.c @@ -251,13 +251,17 @@ lockdownd_error_t lockdownd_client_free(lockdownd_client_t client) * Sets the label to send for requests to lockdownd. * * @param client The lockdown client - * @param label The label to set or NULL to disable + * @param label The label to set or NULL to disable sending a label * */ void lockdownd_client_set_label(lockdownd_client_t client, const char *label) { - if (client) - client->label = strdup(label); + if (client) { + if (client->label) + free(client->label); + + client->label = (label != NULL) ? strdup(label): NULL; + } } /** Polls the iPhone for lockdownd data. @@ -644,7 +648,9 @@ lockdownd_error_t lockdownd_client_new(iphone_device_t device, lockdownd_client_ client_loc->in_SSL = 0; client_loc->session_id = NULL; client_loc->uuid = NULL; - client_loc->label = strdup(label); + client_loc->label = NULL; + if (label != NULL) + strdup(label); if (LOCKDOWN_E_SUCCESS != lockdownd_query_type(client_loc, &type)) { log_debug_msg("%s: QueryType failed in the lockdownd client.\n", __func__); -- cgit v1.1-32-gdbae