summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNikias Bassen <nikias@gmx.li>2019-03-05 02:53:56 +0100
committerNikias Bassen <nikias@gmx.li>2019-03-05 02:53:56 +0100
commitb1b0bf390363fa36aff1bc09443ff751943b9c34 (patch)
tree18aaa8cc8439430a5a88ad23bcfe8f53549c7bc3 /src
parenta236e559cd2bfcd920dc684d06b188abfd6e2c32 (diff)
downloadusbmuxd-b1b0bf390363fa36aff1bc09443ff751943b9c34.tar.gz
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.c17
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)
static void update_client_info(struct mux_client *client, plist_t dict)
{
plist_t node = NULL;
- char *strval = NULL;
- uint64_t u64val = 0;
plist_t info = plist_new_dict();
node = plist_dict_get_item(dict, "BundleID");
if (node && (plist_get_node_type(node) == PLIST_STRING)) {
- plist_get_string_val(node, &strval);
- plist_dict_set_item(info, "BundleID", plist_new_string(strval));
+ plist_dict_set_item(info, "BundleID", plist_copy(node));
}
- strval = NULL;
node = plist_dict_get_item(dict, "ClientVersionString");
if (node && (plist_get_node_type(node) == PLIST_STRING)) {
- plist_get_string_val(node, &strval);
- plist_dict_set_item(info, "ClientVersionString", plist_new_string(strval));
+ plist_dict_set_item(info, "ClientVersionString", plist_copy(node));
}
- strval = NULL;
node = plist_dict_get_item(dict, "ProgName");
if (node && (plist_get_node_type(node) == PLIST_STRING)) {
- plist_get_string_val(node, &strval);
- plist_dict_set_item(info, "ProgName", plist_new_string(strval));
+ plist_dict_set_item(info, "ProgName", plist_copy(node));
}
- u64val = 0;
node = plist_dict_get_item(dict, "kLibUSBMuxVersion");
if (node && (plist_get_node_type(node) == PLIST_UINT)) {
- plist_get_uint_val(node, &u64val);
- plist_dict_set_item(info, "kLibUSBMuxVersion", plist_new_uint(u64val));
+ plist_dict_set_item(info, "kLibUSBMuxVersion", plist_copy(node));
}
plist_free(client->info);
client->info = info;