Skip to content

Commit 08ece7d

Browse files
mgreterxzyfer
authored andcommitted
Fix memory issues reported by clang memory sanitizer
1 parent 24e0bdf commit 08ece7d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/ast.hpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,7 +1737,12 @@ namespace Sass {
17371737

17381738
if (s->statement_type() == Statement::DIRECTIVE)
17391739
{
1740-
return expression()->exclude(static_cast<Directive*>(s)->keyword().erase(0, 1));
1740+
if (Directive* dir = dynamic_cast<Directive*>(s))
1741+
{
1742+
std::string keyword(dir->keyword());
1743+
if (keyword.length() > 0) keyword.erase(0, 1);
1744+
return expression()->exclude(keyword);
1745+
}
17411746
}
17421747
if (s->statement_type() == Statement::MEDIA)
17431748
{
@@ -1751,9 +1756,9 @@ namespace Sass {
17511756
{
17521757
return expression()->exclude("supports");
17531758
}
1754-
if (static_cast<Directive*>(s)->is_keyframes())
1759+
if (Directive* dir = dynamic_cast<Directive*>(s))
17551760
{
1756-
return expression()->exclude("keyframes");
1761+
if (dir->is_keyframes()) return expression()->exclude("keyframes");
17571762
}
17581763
return false;
17591764
}

0 commit comments

Comments
 (0)