Properly handle empty data nodes (such as generated by Apple's

plist editor). They are in the form of <data></data>, whereas the
original code path only checked for empty being <data/>.

This causes an assert to be triggered when trying to access the node's
content.

Patch reviewed by thorpej.
This commit is contained in:
cyber 2009-01-25 06:59:35 +00:00
parent 5a84a46b8c
commit 23dc01f7e9
1 changed files with 16 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: prop_data.c,v 1.13 2008/08/03 04:00:12 thorpej Exp $ */
/* $NetBSD: prop_data.c,v 1.14 2009/01/25 06:59:35 cyber Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
@ -546,7 +546,11 @@ _prop_data_internalize(prop_stack_t stack, prop_object_t *obj,
uint8_t *buf;
size_t len, alen;
/* We don't accept empty elements. */
/*
* We don't accept empty elements.
* This actually only checks for the node to be <data/>
* (Which actually causes another error if found.)
*/
if (ctx->poic_is_empty_element)
return (true);
@ -606,7 +610,16 @@ _prop_data_internalize(prop_stack_t stack, prop_object_t *obj,
return (true);
}
data->pd_mutable = buf;
/*
* Handle alternate type of empty node.
* XML document could contain open/close tags, yet still be empty.
*/
if (alen == 0) {
_PROP_FREE(buf, M_PROP_DATA);
data->pd_mutable = NULL;
} else {
data->pd_mutable = buf;
}
data->pd_size = len;
*obj = data;