Skip to content

Commit

Permalink
ubsan: fix buildflagset "applying non-zero offset to null pointer"
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 committed Feb 5, 2025
1 parent b150f78 commit 4ad4e72
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 4ad4e72

Please sign in to comment.