diff options
Diffstat (limited to 'include/strutils.h')
-rw-r--r-- | include/strutils.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/include/strutils.h b/include/strutils.h index cfe8a9560..4d8463a6d 100644 --- a/include/strutils.h +++ b/include/strutils.h @@ -171,11 +171,14 @@ static inline size_t rtrim_whitespace(unsigned char *str) { size_t i = strlen((char *) str); - while (i--) { - if (!isspace(str[i])) + while (i) { + i--; + if (!isspace(str[i])) { + i++; break; + } } - str[++i] = '\0'; + str[i] = '\0'; return i; } |