Fix empty-object pointers
Pointers are written as offsets to the segment start; leaving p->data as NULL results in invalid pointers for zero-size objects (particularly, lists.)
This commit is contained in:
parent
48ab119048
commit
332076e522
1 changed files with 4 additions and 1 deletions
5
capn.c
5
capn.c
|
|
@ -941,8 +941,11 @@ static void new_object(capn_ptr *p, int bytes) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!bytes)
|
||||
/* pointer needs to be initialised to get a valid offset on write */
|
||||
if (!bytes) {
|
||||
p->data = s->data + s->len;
|
||||
return;
|
||||
}
|
||||
|
||||
/* all allocations are 8 byte aligned */
|
||||
bytes = (bytes + 7) & ~7;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue