From 006990e3ca4fca40902b10b178cd98afecf0cd4a Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Fri, 17 Jul 2009 19:44:40 +0200 Subject: [PATCH] Make sure to also copy string/data buffers when cloning the node data struct --- src/plist.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/src/plist.c b/src/plist.c index c205d46..b6e0aa8 100644 --- a/src/plist.c +++ b/src/plist.c @@ -148,6 +148,20 @@ static void plist_copy_node(GNode * node, gpointer parent_node_ptr) assert(data); // plist should always have data memcpy(newdata, data, sizeof(struct plist_data_s)); + + plist_type node_type = plist_get_node_type(node); + if (node_type == PLIST_DATA || node_type == PLIST_STRING || node_type == PLIST_KEY) { + switch (node_type) { + case PLIST_DATA: + newdata->buff = (uint8_t *) malloc(data->length); + memcpy(newdata->buff, data->buff, data->length); + case PLIST_KEY: + case PLIST_STRING: + newdata->strval = strdup((char *) data->strval); + default: + break; + } + } newnode = plist_new_node(newdata); if (*(plist_t*)parent_node_ptr) { -- 1.6.0.2