sic

The sic programming language, compiler and tools (WIP)
Log | Files | Refs

commit f72041ad10f5530cfcd0198866b1b462d6575024
parent 66593249d58bb5d7565182a15fcc1f0286fceb63
Author: citbl <citbl@citbl.org>
Date:   Tue, 12 May 2026 20:59:23 +1000

fix

Diffstat:
Msrc/str.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/str.c b/src/str.c @@ -7,9 +7,9 @@ void str_append(Str* str, const char c) size_t new_cap; char* s; - if (str->len >= str->cap) { + if (str->len + 1 >= str->cap) { new_cap = str->cap == 0 ? 32 : str->cap * 2; - check(new_cap <= str->cap || new_cap > SIZE_MAX / sizeof(Str), "could not reallocate string\n"); + check(new_cap <= str->cap || new_cap > SIZE_MAX, "could not reallocate string\n"); s = realloc(str->value, new_cap * sizeof(char)); check(s == NULL, "str_append: could not alloc string\n"); str->cap = new_cap;