diff options
| author | cyber <cyber@NetBSD.org> | 2009-01-25 06:59:35 +0000 |
|---|---|---|
| committer | cyber <cyber@NetBSD.org> | 2009-01-25 06:59:35 +0000 |
| commit | 23dc01f7e9af86a095969dbf11248b140daa4aee (patch) | |
| tree | 08b194099ed7179f436fe4072de95a39b75f41c1 /common/lib/libprop | |
| parent | 5a84a46b8c814d85ad905680b955ffe1c7bfef3f (diff) | |
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.
Diffstat (limited to 'common/lib/libprop')
| -rw-r--r-- | common/lib/libprop/prop_data.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/common/lib/libprop/prop_data.c b/common/lib/libprop/prop_data.c index 533de8ac1ba..5ef9e35e307 100644 --- a/common/lib/libprop/prop_data.c +++ b/common/lib/libprop/prop_data.c @@ -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; |
