diff options
| author | 2008-08-17 22:15:44 +0200 | |
|---|---|---|
| committer | 2008-08-21 19:13:35 +0200 | |
| commit | ef6206f51596d3c643dc0efe441ecaa0159f5632 (patch) | |
| tree | 869cb749fcfdb1b06d5ee76f103ac72a72575e05 | |
| parent | ab38ab2ec7166f35aa0b8943d0b9f020c514e024 (diff) | |
| download | libimobiledevice-ef6206f51596d3c643dc0efe441ecaa0159f5632.tar.gz libimobiledevice-ef6206f51596d3c643dc0efe441ecaa0159f5632.tar.bz2 | |
use NULL at end of dictionary values (fixes a memory leak).
| -rw-r--r-- | src/lockdown.c | 12 | ||||
| -rw-r--r-- | src/plist.c | 7 |
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) { | |||
| 202 | xmlFreeDoc(plist); | 202 | xmlFreeDoc(plist); |
| 203 | free(XML_content); | 203 | free(XML_content); |
| 204 | 204 | ||
| 205 | for (i = 0; strcmp(dictionary[i], ""); i+=2) { | 205 | for (i = 0; dictionary[i]; i+=2) { |
| 206 | if (!strcmp(dictionary[i], "Result") && !strcmp(dictionary[i+1], "Success")) { | 206 | if (!strcmp(dictionary[i], "Result") && !strcmp(dictionary[i+1], "Success")) { |
| 207 | free_dictionary(dictionary); | 207 | free_dictionary(dictionary); |
| 208 | if (debug) printf("lockdownd_hello(): success\n"); | 208 | if (debug) printf("lockdownd_hello(): success\n"); |
| @@ -258,7 +258,7 @@ int lockdownd_get_device_public_key(lockdownd_client *control, char **public_key | |||
| 258 | free(XML_content); | 258 | free(XML_content); |
| 259 | 259 | ||
| 260 | int success = 0; | 260 | int success = 0; |
| 261 | for (i = 0; strcmp(dictionary[i], ""); i+=2) { | 261 | for (i = 0; dictionary[i]; i+=2) { |
| 262 | if (!strcmp(dictionary[i], "Result") && !strcmp(dictionary[i+1], "Success")) { | 262 | if (!strcmp(dictionary[i], "Result") && !strcmp(dictionary[i+1], "Success")) { |
| 263 | success = 1; | 263 | success = 1; |
| 264 | } | 264 | } |
| @@ -395,7 +395,7 @@ int lockdownd_pair_device(lockdownd_client *control, char *public_key_b64, char | |||
| 395 | free(XML_content); | 395 | free(XML_content); |
| 396 | 396 | ||
| 397 | int success = 0; | 397 | int success = 0; |
| 398 | for (i = 0; strcmp(dictionary[i], ""); i+=2) { | 398 | for (i = 0; dictionary[i]; i+=2) { |
| 399 | if (!strcmp(dictionary[i], "Result") && !strcmp(dictionary[i+1], "Success")) { | 399 | if (!strcmp(dictionary[i], "Result") && !strcmp(dictionary[i+1], "Success")) { |
| 400 | success = 1; | 400 | success = 1; |
| 401 | } | 401 | } |
| @@ -592,7 +592,7 @@ int lockdownd_start_SSL_session(lockdownd_client *control, const char *HostID) { | |||
| 592 | dictionary = read_dict_element_strings(dict); | 592 | dictionary = read_dict_element_strings(dict); |
| 593 | xmlFreeDoc(plist); | 593 | xmlFreeDoc(plist); |
| 594 | free(what2send); | 594 | free(what2send); |
| 595 | for (i = 0; strcmp(dictionary[i], ""); i+=2) { | 595 | for (i = 0; dictionary[i]; i+=2) { |
| 596 | if (!strcmp(dictionary[i], "Result") && !strcmp(dictionary[i+1], "Success")) { | 596 | if (!strcmp(dictionary[i], "Result") && !strcmp(dictionary[i+1], "Success")) { |
| 597 | // Set up GnuTLS... | 597 | // Set up GnuTLS... |
| 598 | //gnutls_anon_client_credentials_t anoncred; | 598 | //gnutls_anon_client_credentials_t anoncred; |
| @@ -650,7 +650,7 @@ int lockdownd_start_SSL_session(lockdownd_client *control, const char *HostID) { | |||
| 650 | if (debug) { | 650 | if (debug) { |
| 651 | printf("Apparently failed negotiating with lockdownd.\n"); | 651 | printf("Apparently failed negotiating with lockdownd.\n"); |
| 652 | printf("Responding dictionary: \n"); | 652 | printf("Responding dictionary: \n"); |
| 653 | for (i = 0; strcmp(dictionary[i], ""); i+=2) { | 653 | for (i = 0; dictionary[i]; i+=2) { |
| 654 | printf("\t%s: %s\n", dictionary[i], dictionary[i+1]); | 654 | printf("\t%s: %s\n", dictionary[i], dictionary[i+1]); |
| 655 | } | 655 | } |
| 656 | } | 656 | } |
| @@ -814,7 +814,7 @@ int lockdownd_start_service(lockdownd_client *control, const char *service) { | |||
| 814 | if (!dict) return 0; | 814 | if (!dict) return 0; |
| 815 | dictionary = read_dict_element_strings(dict); | 815 | dictionary = read_dict_element_strings(dict); |
| 816 | 816 | ||
| 817 | for (i = 0; strcmp(dictionary[i], ""); i+=2) { | 817 | for (i = 0; dictionary[i]; i+=2) { |
| 818 | if (debug) printf("lockdownd_start_service() dictionary %s: %s\n", dictionary[i], dictionary[i+1]); | 818 | if (debug) printf("lockdownd_start_service() dictionary %s: %s\n", dictionary[i], dictionary[i+1]); |
| 819 | 819 | ||
| 820 | if (!xmlStrcmp(dictionary[i], "Port")) { | 820 | 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) { | |||
| 212 | 212 | ||
| 213 | old = return_me; | 213 | old = return_me; |
| 214 | return_me = realloc(return_me, sizeof(char*) * (current_length+1)); | 214 | return_me = realloc(return_me, sizeof(char*) * (current_length+1)); |
| 215 | return_me[current_pos] = strdup(""); | 215 | return_me[current_pos] = NULL; |
| 216 | 216 | ||
| 217 | return return_me; | 217 | return return_me; |
| 218 | } | 218 | } |
| @@ -224,11 +224,10 @@ void free_dictionary(char **dictionary) { | |||
| 224 | 224 | ||
| 225 | if (!dictionary) return; | 225 | if (!dictionary) return; |
| 226 | 226 | ||
| 227 | for (i = 0; strcmp(dictionary[i], ""); i++) { | 227 | for (i = 0; dictionary[i]; i++) { |
| 228 | free(dictionary[i]); | 228 | free(dictionary[i]); |
| 229 | } | 229 | } |
| 230 | 230 | ||
| 231 | free(dictionary[i]); | ||
| 232 | free(dictionary); | 231 | free(dictionary); |
| 233 | } | 232 | } |
| 234 | 233 | ||
