diff --git a/core/src-c/runes.c b/core/src-c/runes.c index b545c59..17d2da3 100644 --- a/core/src-c/runes.c +++ b/core/src-c/runes.c @@ -1,9 +1,9 @@ #include -isz_t rr_distance_to_last_utf8_rune_start(const char *string, usz_t offset) +isz_t rr_distance_to_last_utf8_rune_start(const char *string, isz_t offset) { usz_t bytes_walked = 0; - while(bytes_walked < offset) + while((offset - bytes_walked) >= 0) { if(bytes_walked > 4) return -1;