From 7c7b112cde30d31f89eb1d964c7e7d0f43b33b75 Mon Sep 17 00:00:00 2001 From: Ian Mitchell Date: Fri, 29 Jul 2016 10:31:31 -0700 Subject: [PATCH] Fix str-slice function with negative size Fixes https://github.com/sass/libsass/issues/2132 --- src/functions.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/functions.cpp b/src/functions.cpp index c185d3e89c..962b982d6f 100644 --- a/src/functions.cpp +++ b/src/functions.cpp @@ -1020,11 +1020,12 @@ namespace Sass { std::string str = unquote(s->value()); size_t size = utf8::distance(str.begin(), str.end()); - if (end_at <= size * -1.0) { end_at += size; } + if (end_at <= size * -1.0 && size > 1) { end_at += size; } if (end_at < 0) { end_at += size + 1; } if (end_at > size) { end_at = (double)size; } if (start_at < 0) { start_at += size + 1; } else if (start_at == 0) { ++ start_at; } + if (end_at == 0) end_at = 1;; if (start_at <= end_at) {