From 5120609e6e81974acd3a2e9704e74e32b770ef6f Mon Sep 17 00:00:00 2001 From: Daniel Holden Date: Sun, 1 Sep 2019 16:21:11 -0400 Subject: [PATCH] fixed bug with trimming string with all space characters --- mpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mpc.c b/mpc.c index befd1b5..9aa5a13 100644 --- a/mpc.c +++ b/mpc.c @@ -2470,7 +2470,7 @@ mpc_val_t *mpcf_strtriml(mpc_val_t *x) { mpc_val_t *mpcf_strtrimr(mpc_val_t *x) { char *s = x; size_t l = strlen(s); - while (isspace((unsigned char)s[l-1])) { + while (l > 0 && isspace((unsigned char)s[l-1])) { s[l-1] = '\0'; l--; } return s;