diff options
Diffstat (limited to 'src/xplist.c')
| -rw-r--r-- | src/xplist.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/xplist.c b/src/xplist.c index 66e1dba..dc5213b 100644 --- a/src/xplist.c +++ b/src/xplist.c @@ -256,7 +256,7 @@ static plist_err_t node_to_xml(node_t node, bytearray_t **outbuf, uint32_t depth /* append tag */ str_buf_append(*outbuf, "<", 1); str_buf_append(*outbuf, tag, tag_len); - if (node_data->type == PLIST_STRING || node_data->type == PLIST_KEY) { + if ((node_data->type == PLIST_STRING || node_data->type == PLIST_KEY) && node_data->length > 0) { size_t j; size_t len; off_t start = 0; @@ -1066,7 +1066,7 @@ static plist_err_t node_from_xml(parse_ctx ctx, plist_t *plist) ctx->err++; goto err_out; } - int taglen = ctx->pos - p; + size_t taglen = ctx->pos - p; tag = (char*)malloc(taglen + 1); strncpy(tag, p, taglen); tag[taglen] = '\0'; @@ -1084,7 +1084,7 @@ static plist_err_t node_from_xml(parse_ctx ctx, plist_t *plist) goto err_out; } if (*(ctx->pos-1) == '/') { - int idx = ctx->pos - p - 1; + size_t idx = ctx->pos - p - 1; if (idx < taglen) tag[idx] = '\0'; is_empty = 1; @@ -1274,6 +1274,14 @@ static plist_err_t node_from_xml(parse_ctx ctx, plist_t *plist) data->length = length; } } else { + if (!strcmp(tag, "key") && !keyname && parent && (plist_get_node_type(parent) == PLIST_DICT)) { + keyname = strdup(""); + free(tag); + tag = NULL; + plist_free(subnode); + subnode = NULL; + continue; + } data->strval = strdup(""); data->length = 0; } |
