diff options
| author | 2009-07-10 19:02:47 +0200 | |
|---|---|---|
| committer | 2009-07-14 22:53:59 +0200 | |
| commit | f605777d9739d2f8873b9ab65929e8aee1ebb64e (patch) | |
| tree | 919257855086ef9f981b22a8d3229355a3a76e87 | |
| parent | 365e1199ee8d42b3ee66b098f883b08bb172d51f (diff) | |
| download | libplist-f605777d9739d2f8873b9ab65929e8aee1ebb64e.tar.gz libplist-f605777d9739d2f8873b9ab65929e8aee1ebb64e.tar.bz2 | |
Make sure to also copy string/data buffers when cloning the node data struct
| -rw-r--r-- | src/plist.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/plist.c b/src/plist.c index c205d46..8c326af 100644 --- a/src/plist.c +++ b/src/plist.c | |||
| @@ -148,6 +148,19 @@ static void plist_copy_node(GNode * node, gpointer parent_node_ptr) | |||
| 148 | assert(data); // plist should always have data | 148 | assert(data); // plist should always have data |
| 149 | 149 | ||
| 150 | memcpy(newdata, data, sizeof(struct plist_data_s)); | 150 | memcpy(newdata, data, sizeof(struct plist_data_s)); |
| 151 | |||
| 152 | plist_type node_type = plist_get_node_type(node); | ||
| 153 | if (node_type == PLIST_DATA || node_type == PLIST_STRING) { | ||
| 154 | switch (node_type) { | ||
| 155 | case PLIST_DATA: | ||
| 156 | newdata->buff = (uint8_t *) malloc(data->length); | ||
| 157 | memcpy(newdata->buff, data->buff, data->length); | ||
| 158 | case PLIST_STRING: | ||
| 159 | newdata->strval = strdup((char *) data->strval); | ||
| 160 | default: | ||
| 161 | break; | ||
| 162 | } | ||
| 163 | } | ||
| 151 | newnode = plist_new_node(newdata); | 164 | newnode = plist_new_node(newdata); |
| 152 | 165 | ||
| 153 | if (*(plist_t*)parent_node_ptr) { | 166 | if (*(plist_t*)parent_node_ptr) { |
