From b803771c1aa4fbe7d9cb5ffdaeef3462cc3f428e Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Mon, 25 Apr 2022 20:47:24 +0200 Subject: [PATCH] :art: Fix string slice negative index --- src/lib/string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/string.c b/src/lib/string.c index 0ef3a389..f1c27604 100644 --- a/src/lib/string.c +++ b/src/lib/string.c @@ -81,7 +81,7 @@ static INSTR(StringSlice) { const m_int start = *(m_uint *)REG(0); const size_t strsz = strlen(str); m_int end = *(m_uint *)REG(SZ_INT); - if (end < 0) end = strsz + end; + if (end < 0) end = strsz + end - 1; if (bounds(str, start) < 0 || bounds(str, end) < 0) { handle(shred, "OutOfBoundsStringSlice"); return; -- 2.43.0