summaryrefslogtreecommitdiffstats
path: root/common/userpref.c
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2013-10-08 23:59:30 +0200
committerGravatar Martin Szulecki2013-10-08 23:59:30 +0200
commitf5425a9e9acdf9d6b59461a083e9da8c52be6df1 (patch)
tree1a45df22afb04929a1457536a094b476cd40c154 /common/userpref.c
parent744e014d5240b8621b8b8a2aec954641e18d3ac7 (diff)
downloadlibimobiledevice-f5425a9e9acdf9d6b59461a083e9da8c52be6df1.tar.gz
libimobiledevice-f5425a9e9acdf9d6b59461a083e9da8c52be6df1.tar.bz2
userpref: Free some plist return values to fix a few memory leaks
Diffstat (limited to 'common/userpref.c')
-rw-r--r--common/userpref.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/common/userpref.c b/common/userpref.c
index d84cdac..664ba25 100644
--- a/common/userpref.c
+++ b/common/userpref.c
@@ -392,6 +392,9 @@ void userpref_get_system_buid(char **system_buid)
392 debug_info("got %s %s", USERPREF_SYSTEM_BUID_KEY, *system_buid); 392 debug_info("got %s %s", USERPREF_SYSTEM_BUID_KEY, *system_buid);
393 } 393 }
394 394
395 if (value)
396 plist_free(value);
397
395 if (!*system_buid) { 398 if (!*system_buid) {
396 /* no config, generate system_buid */ 399 /* no config, generate system_buid */
397 debug_info("no previous %s found", USERPREF_SYSTEM_BUID_KEY); 400 debug_info("no previous %s found", USERPREF_SYSTEM_BUID_KEY);
@@ -412,6 +415,9 @@ void userpref_device_record_get_host_id(const char *udid, char **host_id)
412 plist_get_string_val(value, host_id); 415 plist_get_string_val(value, host_id);
413 } 416 }
414 417
418 if (value)
419 plist_free(value);
420
415 if (!*host_id) { 421 if (!*host_id) {
416 /* no config, generate host_id */ 422 /* no config, generate host_id */
417 *host_id = userpref_generate_host_id(0); 423 *host_id = userpref_generate_host_id(0);
@@ -1051,9 +1057,11 @@ userpref_error_t userpref_device_record_get_certs_as_pem(const char *udid, key_d
1051 1057
1052 char* buffer = NULL; 1058 char* buffer = NULL;
1053 uint64_t length = 0; 1059 uint64_t length = 0;
1060
1054 plist_t root_cert = NULL; 1061 plist_t root_cert = NULL;
1055 plist_t host_cert = NULL; 1062 plist_t host_cert = NULL;
1056 plist_t dev_cert = NULL; 1063 plist_t dev_cert = NULL;
1064
1057 if (userpref_device_record_get_value(udid, USERPREF_HOST_CERTIFICATE_KEY, &host_cert) && 1065 if (userpref_device_record_get_value(udid, USERPREF_HOST_CERTIFICATE_KEY, &host_cert) &&
1058 userpref_device_record_get_value(udid, USERPREF_ROOT_CERTIFICATE_KEY, &root_cert)) { 1066 userpref_device_record_get_value(udid, USERPREF_ROOT_CERTIFICATE_KEY, &root_cert)) {
1059 if (host_cert && plist_get_node_type(host_cert) == PLIST_DATA) { 1067 if (host_cert && plist_get_node_type(host_cert) == PLIST_DATA) {
@@ -1097,6 +1105,13 @@ userpref_error_t userpref_device_record_get_certs_as_pem(const char *udid, key_d
1097 } 1105 }
1098 } 1106 }
1099 1107
1108 if (root_cert)
1109 plist_free(root_cert);
1110 if (host_cert)
1111 plist_free(host_cert);
1112 if (dev_cert)
1113 plist_free(dev_cert);
1114
1100 debug_info("configuration invalid"); 1115 debug_info("configuration invalid");
1101 1116
1102 return USERPREF_E_INVALID_CONF; 1117 return USERPREF_E_INVALID_CONF;