Skip to content

Fix(warnings): size WarningArray arena by Clay__Warning - #660

Open
r3wretrhy wants to merge 1 commit into
nicbarker:mainfrom
r3wretrhy:fix/warning-array-sizeof-638
Open

r3wretrhy wants to merge 1 commit into
nicbarker:mainfrom
r3wretrhy:fix/warning-array-sizeof-638

Conversation

@r3wretrhy

Copy link
Copy Markdown

Summary

Fixes #638.

Clay__WarningArray_Allocate_Arena reserved capacity * sizeof(Clay_String) bytes while the array stores Clay__Warning (two Clay_String fields). With the usual capacity of 100 that only fits 50 warnings, but Clay__WarningArray_Add still range-checks against capacity 100, so an Add past slot 49 would write past the arena slab.

The reporter noted Add is currently unused in-tree; this still corrects the allocator so capacity and storage agree if warnings are ever recorded again.

Change: size the slab with sizeof(Clay__Warning).

Test plan

Host harness (not committed) that calls Clay__WarningArray_Allocate_Arena(100, …) and measures the arena advance after alignment:

  • Before: totalSizeBytes=1600 (100 * sizeof(Clay_String)), real_slots_fitting=50, claimed capacity 100 → fail
  • After: totalSizeBytes=3200 (100 * sizeof(Clay__Warning)), real_slots_fitting=100 → pass

No CONTRIBUTING / AGENTS / PR template requirements found; no AI disclosure requested by the project.

Clay__WarningArray_Allocate_Arena used sizeof(Clay_String) while the
array stores Clay__Warning (two Clay_String fields). With capacity 100
that reserved only 50 slots but range checks still used capacity 100,
so Clay__WarningArray_Add could write past the arena slab.

Fixes nicbarker#638.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Question] WarningArray allocation uses sizeof(Clay_String) instead of sizeof(Clay_Warning)

1 participant