Skip to content

Commit

Permalink
Fix buildflagset "applying non-zero offset to null pointer" (#4599)
Browse files Browse the repository at this point in the history
ubsan doesn't like that buildflagset adds offsets to null pointers.
This commit fixes things to ensure that buildflagset always has a
valid text buffer to work with.

Makes ubsan runtime errors such as the following go away:

`runtime error: applying non-zero offset 11 to null pointer`
  • Loading branch information
dipinhora authored Feb 6, 2025
1 parent c96929b commit 23d046e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/libponyc/pkg/buildflagset.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,9 @@ buildflagset_t* buildflagset_create()
p->started_enum = false;
p->flags = POOL_ALLOC(flagtab_t);
flagtab_init(p->flags, 8);
p->text_buffer = NULL;
p->buffer_size = 0;
p->text_buffer = (char*)ponyint_pool_alloc_size(1);
p->buffer_size = 1;
p->text_buffer[0] = '\0';

return p;
}
Expand Down

0 comments on commit 23d046e

Please sign in to comment.