diff options
| author | 2019-03-05 02:53:56 +0100 | |
|---|---|---|
| committer | 2019-03-05 02:53:56 +0100 | |
| commit | b1b0bf390363fa36aff1bc09443ff751943b9c34 (patch) | |
| tree | 18aaa8cc8439430a5a88ad23bcfe8f53549c7bc3 /src | |
| parent | a236e559cd2bfcd920dc684d06b188abfd6e2c32 (diff) | |
| download | usbmuxd-b1b0bf390363fa36aff1bc09443ff751943b9c34.tar.gz usbmuxd-b1b0bf390363fa36aff1bc09443ff751943b9c34.tar.bz2 | |
client: Plug memory leaks in update_client_info()
plist_get_string_val() was used to get the string values of the
respective nodes, however those strings were never freed.
Improved by simply copying the nodes instead.
Diffstat (limited to 'src')
| -rw-r--r-- | src/client.c | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/client.c b/src/client.c index 3472e6e..85d0c8b 100644 --- a/src/client.c +++ b/src/client.c | |||
| @@ -579,35 +579,26 @@ static char* plist_dict_get_string_val(plist_t dict, const char* key) | |||
| 579 | static void update_client_info(struct mux_client *client, plist_t dict) | 579 | static void update_client_info(struct mux_client *client, plist_t dict) |
| 580 | { | 580 | { |
| 581 | plist_t node = NULL; | 581 | plist_t node = NULL; |
| 582 | char *strval = NULL; | ||
| 583 | uint64_t u64val = 0; | ||
| 584 | plist_t info = plist_new_dict(); | 582 | plist_t info = plist_new_dict(); |
| 585 | 583 | ||
| 586 | node = plist_dict_get_item(dict, "BundleID"); | 584 | node = plist_dict_get_item(dict, "BundleID"); |
| 587 | if (node && (plist_get_node_type(node) == PLIST_STRING)) { | 585 | if (node && (plist_get_node_type(node) == PLIST_STRING)) { |
| 588 | plist_get_string_val(node, &strval); | 586 | plist_dict_set_item(info, "BundleID", plist_copy(node)); |
| 589 | plist_dict_set_item(info, "BundleID", plist_new_string(strval)); | ||
| 590 | } | 587 | } |
| 591 | 588 | ||
| 592 | strval = NULL; | ||
| 593 | node = plist_dict_get_item(dict, "ClientVersionString"); | 589 | node = plist_dict_get_item(dict, "ClientVersionString"); |
| 594 | if (node && (plist_get_node_type(node) == PLIST_STRING)) { | 590 | if (node && (plist_get_node_type(node) == PLIST_STRING)) { |
| 595 | plist_get_string_val(node, &strval); | 591 | plist_dict_set_item(info, "ClientVersionString", plist_copy(node)); |
| 596 | plist_dict_set_item(info, "ClientVersionString", plist_new_string(strval)); | ||
| 597 | } | 592 | } |
| 598 | 593 | ||
| 599 | strval = NULL; | ||
| 600 | node = plist_dict_get_item(dict, "ProgName"); | 594 | node = plist_dict_get_item(dict, "ProgName"); |
| 601 | if (node && (plist_get_node_type(node) == PLIST_STRING)) { | 595 | if (node && (plist_get_node_type(node) == PLIST_STRING)) { |
| 602 | plist_get_string_val(node, &strval); | 596 | plist_dict_set_item(info, "ProgName", plist_copy(node)); |
| 603 | plist_dict_set_item(info, "ProgName", plist_new_string(strval)); | ||
| 604 | } | 597 | } |
| 605 | 598 | ||
| 606 | u64val = 0; | ||
| 607 | node = plist_dict_get_item(dict, "kLibUSBMuxVersion"); | 599 | node = plist_dict_get_item(dict, "kLibUSBMuxVersion"); |
| 608 | if (node && (plist_get_node_type(node) == PLIST_UINT)) { | 600 | if (node && (plist_get_node_type(node) == PLIST_UINT)) { |
| 609 | plist_get_uint_val(node, &u64val); | 601 | plist_dict_set_item(info, "kLibUSBMuxVersion", plist_copy(node)); |
| 610 | plist_dict_set_item(info, "kLibUSBMuxVersion", plist_new_uint(u64val)); | ||
| 611 | } | 602 | } |
| 612 | plist_free(client->info); | 603 | plist_free(client->info); |
| 613 | client->info = info; | 604 | client->info = info; |
