Skip to content

Commit ddc2e87

Browse files
committed
Bound whitespace scans before reading
1 parent 5de6ecd commit ddc2e87

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/string.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ rbs_string_t rbs_string_new(const char *start, const char *end) {
1414

1515
rbs_string_t rbs_string_strip_whitespace(rbs_string_t *self) {
1616
const char *new_start = self->start;
17-
while (isspace(*new_start) && new_start < self->end) {
17+
while (new_start < self->end && isspace((unsigned char) *new_start)) {
1818
new_start++;
1919
}
2020

@@ -23,7 +23,7 @@ rbs_string_t rbs_string_strip_whitespace(rbs_string_t *self) {
2323
}
2424

2525
const char *new_end = self->end - 1;
26-
while (isspace(*new_end) && new_start < new_end) {
26+
while (new_start < new_end && isspace((unsigned char) *new_end)) {
2727
new_end--;
2828
}
2929

0 commit comments

Comments
 (0)