summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Jonathan Beck2008-12-13 18:10:39 +0100
committerGravatar Jonathan Beck2008-12-13 18:10:39 +0100
commit2a514976045c878766dc6975d03b1b3eb1a86eed (patch)
tree340134ccf72ffa2ca4a47e98a7a985f5a6acb2b2
parent3f0dfcf5f77659877f57c00f307ed46a96d0d0d1 (diff)
downloadlibplist-2a514976045c878766dc6975d03b1b3eb1a86eed.tar.gz
libplist-2a514976045c878766dc6975d03b1b3eb1a86eed.tar.bz2
Fix node length while parsing XML.
-rw-r--r--src/plist.c7
-rw-r--r--src/xplist.c6
2 files changed, 9 insertions, 4 deletions
diff --git a/src/plist.c b/src/plist.c
index 81cdfc5..1fafd94 100644
--- a/src/plist.c
+++ b/src/plist.c
@@ -75,7 +75,7 @@ plist_t plist_new_array()
plist_t plist_add_sub_element(plist_t node, plist_type type, void *value, uint64_t length)
{
//only structured types are allowed to have nulll value
- if (!value && (type == PLIST_DICT || type == PLIST_ARRAY)) {
+ if (value || (!value && (type == PLIST_DICT || type == PLIST_ARRAY))) {
//now handle value
plist_data_t data = plist_new_plist_data();
data->type = type;
@@ -91,6 +91,7 @@ plist_t plist_add_sub_element(plist_t node, plist_type type, void *value, uint64
case PLIST_REAL:
data->realval = *((double *) value);
break;
+ case PLIST_KEY:
case PLIST_STRING:
data->strval = strdup((char *) value);
break;
@@ -209,15 +210,13 @@ void plist_get_type_and_value(plist_t node, plist_type * type, void *value, uint
case PLIST_REAL:
*((double *) value) = data->realval;
break;
+ case PLIST_KEY:
case PLIST_STRING:
*((char **) value) = strdup(data->strval);
break;
case PLIST_UNICODE:
*((wchar_t **) value) = wcsdup(data->unicodeval);
break;
- case PLIST_KEY:
- *((char **) value) = strdup(data->strval);
- break;
case PLIST_DATA:
case PLIST_ARRAY:
case PLIST_DICT:
diff --git a/src/xplist.c b/src/xplist.c
index 6c27375..9a5698c 100644
--- a/src/xplist.c
+++ b/src/xplist.c
@@ -230,12 +230,14 @@ void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
if (!xmlStrcmp(node->name, "true")) {
data->boolval = 1;
data->type = PLIST_BOOLEAN;
+ data->length = 1;
continue;
}
if (!xmlStrcmp(node->name, "false")) {
data->boolval = 0;
data->type = PLIST_BOOLEAN;
+ data->length = 1;
continue;
}
@@ -243,6 +245,7 @@ void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
char *strval = xmlNodeGetContent(node);
data->intval = g_ascii_strtoull(strval, NULL, 0);
data->type = PLIST_UINT;
+ data->length = 8;
continue;
}
@@ -250,6 +253,7 @@ void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
char *strval = xmlNodeGetContent(node);
data->realval = atof(strval);
data->type = PLIST_REAL;
+ data->length = 8;
continue;
}
@@ -259,12 +263,14 @@ void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
if (!xmlStrcmp(node->name, "string")) {
data->strval = strdup(xmlNodeGetContent(node));
data->type = PLIST_STRING;
+ data->length = strlen(data->strval);
continue;
}
if (!xmlStrcmp(node->name, "key")) {
data->strval = strdup(xmlNodeGetContent(node));
data->type = PLIST_KEY;
+ data->length = strlen(data->strval);
continue;
}