summaryrefslogtreecommitdiffstats
path: root/src/out-plutil.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2026-11-05 12:01:59 +0100
committerGravatar Nikias Bassen2026-11-05 12:01:59 +0100
commit4dc93bc274867b42aa82fc91ee4d5878d23a3f36 (patch)
tree11c566b80561bb44018bceea028ea03d47e53458 /src/out-plutil.c
parentf252f243f9774b2b830172b49aa340d6994d8081 (diff)
downloadlibplist-4dc93bc274867b42aa82fc91ee4d5878d23a3f36.tar.gz
libplist-4dc93bc274867b42aa82fc91ee4d5878d23a3f36.tar.bz2
Harden allocation failure handling and size arithmetic
- check malloc/calloc/realloc results in constructors, the JSON and OpenStep writers, the XML text-part helpers and base64 decoding, and return PLIST_ERR_NO_MEM instead of asserting or dereferencing NULL - guard size calculations against overflow in the UTF-8/UTF-16BE conversions, ptrarray, and bytearray - make hash_table_insert() report failure instead of silently dropping the entry; writers propagate PLIST_ERR_NO_MEM, and dict lookup caches are discarded so lookups fall back to a linear search - don't overwrite an earlier parse error code in the XML parser, and report PLIST_ERR_NO_MEM when reading text content fails for lack of memory - OpenStep parser: check node/data/string allocations and dict/array insertion results Based on #323 by bg0d-droid. Co-authored-by: bg0d-droid <81825610+bg0d-droid@users.noreply.github.com>
Diffstat (limited to 'src/out-plutil.c')
-rw-r--r--src/out-plutil.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/out-plutil.c b/src/out-plutil.c
index ef17b7c..52edaaf 100644
--- a/src/out-plutil.c
+++ b/src/out-plutil.c
@@ -311,7 +311,9 @@ static plist_err_t _node_estimate_size(node_t node, uint64_t *size, uint32_t dep
}
// mark as visited
- hash_table_insert(visited, node, (void*)1);
+ if (hash_table_insert(visited, node, (void*)1) < 0) {
+ return PLIST_ERR_NO_MEM;
+ }
data = plist_get_data(node);
if (node->children) {