summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Jonathan Beck2008-08-17 22:15:44 +0200
committerGravatar Jonathan Beck2008-08-21 19:13:35 +0200
commitef6206f51596d3c643dc0efe441ecaa0159f5632 (patch)
tree869cb749fcfdb1b06d5ee76f103ac72a72575e05
parentab38ab2ec7166f35aa0b8943d0b9f020c514e024 (diff)
downloadlibimobiledevice-ef6206f51596d3c643dc0efe441ecaa0159f5632.tar.gz
libimobiledevice-ef6206f51596d3c643dc0efe441ecaa0159f5632.tar.bz2
use NULL at end of dictionary values (fixes a memory leak).
-rw-r--r--src/lockdown.c12
-rw-r--r--src/plist.c7
2 files changed, 9 insertions, 10 deletions
diff --git a/src/lockdown.c b/src/lockdown.c
index 76dbf7b..7f48dda 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -202,7 +202,7 @@ int lockdownd_hello(lockdownd_client *control) {
xmlFreeDoc(plist);
free(XML_content);
- for (i = 0; strcmp(dictionary[i], ""); i+=2) {
+ for (i = 0; dictionary[i]; i+=2) {
if (!strcmp(dictionary[i], "Result") && !strcmp(dictionary[i+1], "Success")) {
free_dictionary(dictionary);
if (debug) printf("lockdownd_hello(): success\n");
@@ -258,7 +258,7 @@ int lockdownd_get_device_public_key(lockdownd_client *control, char **public_key
free(XML_content);
int success = 0;
- for (i = 0; strcmp(dictionary[i], ""); i+=2) {
+ for (i = 0; dictionary[i]; i+=2) {
if (!strcmp(dictionary[i], "Result") && !strcmp(dictionary[i+1], "Success")) {
success = 1;
}
@@ -395,7 +395,7 @@ int lockdownd_pair_device(lockdownd_client *control, char *public_key_b64, char
free(XML_content);
int success = 0;
- for (i = 0; strcmp(dictionary[i], ""); i+=2) {
+ for (i = 0; dictionary[i]; i+=2) {
if (!strcmp(dictionary[i], "Result") && !strcmp(dictionary[i+1], "Success")) {
success = 1;
}
@@ -592,7 +592,7 @@ int lockdownd_start_SSL_session(lockdownd_client *control, const char *HostID) {
dictionary = read_dict_element_strings(dict);
xmlFreeDoc(plist);
free(what2send);
- for (i = 0; strcmp(dictionary[i], ""); i+=2) {
+ for (i = 0; dictionary[i]; i+=2) {
if (!strcmp(dictionary[i], "Result") && !strcmp(dictionary[i+1], "Success")) {
// Set up GnuTLS...
//gnutls_anon_client_credentials_t anoncred;
@@ -650,7 +650,7 @@ int lockdownd_start_SSL_session(lockdownd_client *control, const char *HostID) {
if (debug) {
printf("Apparently failed negotiating with lockdownd.\n");
printf("Responding dictionary: \n");
- for (i = 0; strcmp(dictionary[i], ""); i+=2) {
+ for (i = 0; dictionary[i]; i+=2) {
printf("\t%s: %s\n", dictionary[i], dictionary[i+1]);
}
}
@@ -814,7 +814,7 @@ int lockdownd_start_service(lockdownd_client *control, const char *service) {
if (!dict) return 0;
dictionary = read_dict_element_strings(dict);
- for (i = 0; strcmp(dictionary[i], ""); i+=2) {
+ for (i = 0; dictionary[i]; i+=2) {
if (debug) printf("lockdownd_start_service() dictionary %s: %s\n", dictionary[i], dictionary[i+1]);
if (!xmlStrcmp(dictionary[i], "Port")) {
diff --git a/src/plist.c b/src/plist.c
index e64cff2..31490d0 100644
--- a/src/plist.c
+++ b/src/plist.c
@@ -212,7 +212,7 @@ char **read_dict_element_strings(xmlNode *dict) {
old = return_me;
return_me = realloc(return_me, sizeof(char*) * (current_length+1));
- return_me[current_pos] = strdup("");
+ return_me[current_pos] = NULL;
return return_me;
}
@@ -224,11 +224,10 @@ void free_dictionary(char **dictionary) {
if (!dictionary) return;
- for (i = 0; strcmp(dictionary[i], ""); i++) {
+ for (i = 0; dictionary[i]; i++) {
free(dictionary[i]);
}
-
- free(dictionary[i]);
+
free(dictionary);
}