Skip to content

Commit

Permalink
Merge pull request sass#2949 from nschonni/fix--non-integers-passed-t…
Browse files Browse the repository at this point in the history
…o-str-slice

fix: non-integers passed to str-slice
  • Loading branch information
nschonni authored Jul 26, 2019
2 parents 2263d9b + 44e7a9e commit eb54de6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/fn_strings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ namespace Sass {
String_Constant* s = ARG("$string", String_Constant);
double start_at = ARGVAL("$start-at");
double end_at = ARGVAL("$end-at");

if (start_at != (int)start_at) {
error("$start-at: " + std::to_string(start_at) + " is not an int", pstate, traces);
}

String_Quoted* ss = Cast<String_Quoted>(s);

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

if (end_at != (int)end_at) {
error("$end-at: " + std::to_string(end_at) + " is not an int", pstate, traces);
}

if (end_at == 0 || (end_at + size) < 0) {
if (ss && ss->quote_mark()) newstr = quote("");
return SASS_MEMORY_NEW(String_Quoted, pstate, newstr);
Expand Down

0 comments on commit eb54de6

Please sign in to comment.