jcs
/subtext
/amendments
/217
bile: Fix unmarshalling of a dynamic field with zero length
Don't xmalloc(0), just set it to a NULL pointer.
jcs made amendment 217 over 2 years ago
--- bile.c Fri Jul 15 21:39:49 2022
+++ bile.c Tue Jul 19 13:30:56 2022
@@ -23,7 +23,6 @@ static short _bile_error = 0;
static short _bile_open_ignore_primary_map = 0;
-void bile_find_highest_ids(struct bile *bile);
struct bile_object * bile_alloc(struct bile *bile, const OSType type,
const unsigned long id, const size_t size);
struct bile_object * bile_object_in_map(struct bile *bile,
@@ -725,8 +724,12 @@ bile_unmarshall_object(struct bile *bile,
n + 1, nfields);
ptr = (char *)object + fields[n].struct_off;
-
+
if (fields[n].size < 0 && deep) {
+ if (fsize == 0) {
+ memset(ptr, 0, sizeof(dptr));
+ continue;
+ }
dptr = xmalloc(fsize);
memcpy(ptr, &dptr, sizeof(dptr));
ptr = dptr;