Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
Fix out-of-range string access in special_number
Browse files Browse the repository at this point in the history
Out-of-range string access happened when `s->value()` was shorter than "var(" or "calc(".
  • Loading branch information
glebm authored and xzyfer committed Nov 23, 2018
1 parent 534065c commit 5801404
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/fn_colors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ namespace Sass {

bool special_number(String_Constant_Ptr s) {
if (s) {
std::string calc("calc(");
std::string var("var(");
std::string ss(s->value());
return std::equal(calc.begin(), calc.end(), ss.begin()) ||
std::equal(var.begin(), var.end(), ss.begin());
static const char* const calc = "calc(";
static const char* const var = "var(";
const std::string& str = s->value();
return str.compare(0, strlen(calc), calc) == 0 ||
str.compare(0, strlen(var), var) == 0;
}
return false;
}
Expand Down

0 comments on commit 5801404

Please sign in to comment.