Skip to content

Add bounds-checking to strat and strat! - #269

Merged
skx merged 8 commits into
mainfrom
268-bounds-checking
Sep 28, 2026
Merged

skx merged 8 commits into
mainfrom
268-bounds-checking

Conversation

@skx

@skx skx commented Sep 28, 2026

Copy link
Copy Markdown
Owner

This pull-request closes #268 by adding bounds-checking to the strat and strat! functions.

This was more annoying that I'd like because of course not all strings are heap-allocated. Something like:

     (let ((x "steve"))   .. )

Has a string which is staticly allocated, and not heap-based. That means that my original plan to use the "secret" header prefixed to all heap-allocations as a means of determining the length of the memory was doomed... To resolve this I added a fake-header to all static strings too, which means they can now be treated identically.

I added an internal methoed alen to return allocation lengths too for neatness, though it is undocumented.

skx added 8 commits September 28, 2026 18:15
This commit adds bound-checking for heap-allocated strings
for the `strat` and `strat!` functions.

However I realized that it doesn't work for static/inline
strings as they are not prefixed with a header.
Because static strings aren't heap-allocated (d'oh) they
don't have the secret header prefixed so we can't test
their bounds.

Add a fake header.  Add a method for getting the size of
strings to make sure it works.
@skx
skx merged commit 77e092d into main Sep 28, 2026
1 check passed
@skx
skx deleted the 268-bounds-checking branch September 28, 2026 16:05
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.

Add bounds-checking to strat and strat!.

1 participant