From 5d03133a3ea48721033e3c884181d562be106d2f Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Tue, 25 Aug 2026 12:47:03 -0400 Subject: str: Fix to_c_str() when length is MAX_ALLOC_32 Signed-off-by: Andrew Opalach --- include/al/str.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/al/str.h b/include/al/str.h index 20a1c26..a572dec 100644 --- a/include/al/str.h +++ b/include/al/str.h @@ -79,9 +79,10 @@ static inline void al_str_to_upper(str *s) // Returned c_str must be free'd by the user. static inline char *al_str_to_c_str(str *s) { - char *c_str = (char *)al_malloc(s->length + 1); - al_memcpy(c_str, s->data, s->length); - c_str[s->length] = '\0'; + size_t length = (size_t)s->length; + char *c_str = (char *)al_malloc(length + 1); + al_memcpy(c_str, s->data, length); + c_str[length] = '\0'; return c_str; } -- cgit v1.2.3-101-g0448