Skip to content

Commit eb54de6

Browse files
authored
Merge pull request #2949 from nschonni/fix--non-integers-passed-to-str-slice
fix: non-integers passed to str-slice
2 parents 2263d9b + 44e7a9e commit eb54de6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/fn_strings.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ namespace Sass {
166166
String_Constant* s = ARG("$string", String_Constant);
167167
double start_at = ARGVAL("$start-at");
168168
double end_at = ARGVAL("$end-at");
169+
170+
if (start_at != (int)start_at) {
171+
error("$start-at: " + std::to_string(start_at) + " is not an int", pstate, traces);
172+
}
173+
169174
String_Quoted* ss = Cast<String_Quoted>(s);
170175

171176
std::string str(s->value());
@@ -176,6 +181,10 @@ namespace Sass {
176181
end_at = -1;
177182
}
178183

184+
if (end_at != (int)end_at) {
185+
error("$end-at: " + std::to_string(end_at) + " is not an int", pstate, traces);
186+
}
187+
179188
if (end_at == 0 || (end_at + size) < 0) {
180189
if (ss && ss->quote_mark()) newstr = quote("");
181190
return SASS_MEMORY_NEW(String_Quoted, pstate, newstr);

0 commit comments

Comments
 (0)