summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2018-09-04 16:37:04 +0200
committerGravatar Nikias Bassen2018-09-04 16:37:04 +0200
commit2e67a01ba65ee3ac2a028dab2d636227616673ef (patch)
tree2a02c6d1403caefc4f9aadfc5e3193ad750352be
parentdb68a9d1070b363eee93147f072f46526064acbc (diff)
downloadlibplist-2e67a01ba65ee3ac2a028dab2d636227616673ef.tar.gz
libplist-2e67a01ba65ee3ac2a028dab2d636227616673ef.tar.bz2
xplist: Assert when number of child nodes of PLIST_DICT is not even
This should only happen due to misuse of the library, e.g. when calling plist_free() on a node that is a value node in a PLIST_DICT without properly removing the dictionary entry (key/value pair) and then calling plist_to_xml() on that dictionary.
-rw-r--r--src/xplist.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/xplist.c b/src/xplist.c
index 44bb5e7..6e64427 100644
--- a/src/xplist.c
+++ b/src/xplist.c
@@ -353,6 +353,9 @@ static void node_to_xml(node_t* node, bytearray_t **outbuf, uint32_t depth)
str_buf_append(*outbuf, "\n", 1);
if (isStruct) {
+ if (node_data->type == PLIST_DICT) {
+ assert((node->children->count % 2) == 0);
+ }
node_iterator_t *ni = node_iterator_create(node->children);
node_t *ch;
while ((ch = node_iterator_next(ni))) {