From: Jérémie Astor Date: Mon, 25 Apr 2022 18:47:24 +0000 (+0200) Subject: :art: Fix string slice negative index X-Git-Tag: nightly~275^2~45 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=b803771c1aa4fbe7d9cb5ffdaeef3462cc3f428e;p=gwion.git :art: Fix string slice negative index --- 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;