From ddc2e87281aacf6026c323bda322a34188d41538 Mon Sep 17 00:00:00 2001 From: Oskar Eichler Date: Sat, 29 Aug 2026 17:42:44 +0200 Subject: [PATCH] Bound whitespace scans before reading --- src/string.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/string.c b/src/string.c index 6081739f92..18d599fdc5 100644 --- a/src/string.c +++ b/src/string.c @@ -14,7 +14,7 @@ rbs_string_t rbs_string_new(const char *start, const char *end) { rbs_string_t rbs_string_strip_whitespace(rbs_string_t *self) { const char *new_start = self->start; - while (isspace(*new_start) && new_start < self->end) { + while (new_start < self->end && isspace((unsigned char) *new_start)) { new_start++; } @@ -23,7 +23,7 @@ rbs_string_t rbs_string_strip_whitespace(rbs_string_t *self) { } const char *new_end = self->end - 1; - while (isspace(*new_end) && new_start < new_end) { + while (new_start < new_end && isspace((unsigned char) *new_end)) { new_end--; }