Skip to content

Commit 5b9572e

Browse files
authored
Merge pull request #2505 from mgreter/bugfix/mem-leak
Fix memory leak by removing previously unused code
2 parents 16df2e5 + 66a0e5f commit 5b9572e

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

src/eval.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1773,7 +1773,7 @@ namespace Sass {
17731773
Complex_Selector_Ptr is = resolved->at(i)->first();
17741774
while (is) {
17751775
if (is->head()) {
1776-
is->head()->perform(this);
1776+
is->head(operator()(is->head()));
17771777
}
17781778
is = is->tail();
17791779
}
@@ -1785,21 +1785,13 @@ namespace Sass {
17851785
{
17861786
for (size_t i = 0; i < s->length(); i++) {
17871787
Simple_Selector_Ptr ss = s->at(i);
1788-
if (ss) ss->perform(this);
1788+
// skip parents here (called via resolve_parent_refs)
1789+
if (ss == NULL || Cast<Parent_Selector>(ss)) continue;
1790+
s->at(i) = Cast<Simple_Selector>(ss->perform(this));
17891791
}
17901792
return s;
17911793
}
17921794

1793-
// XXX: this is never hit via spec tests
1794-
Attribute_Selector_Ptr Eval::operator()(Attribute_Selector_Ptr s)
1795-
{
1796-
String_Obj attr = s->value();
1797-
if (attr) { attr = static_cast<String_Ptr>(attr->perform(this)); }
1798-
Attribute_Selector_Ptr ss = SASS_MEMORY_COPY(s);
1799-
ss->value(attr);
1800-
return ss;
1801-
}
1802-
18031795
Selector_List_Ptr Eval::operator()(Selector_Schema_Ptr s)
18041796
{
18051797
LOCAL_FLAG(is_in_selector_schema, true);
@@ -1847,6 +1839,11 @@ namespace Sass {
18471839
}
18481840
}
18491841

1842+
Simple_Selector_Ptr Eval::operator()(Simple_Selector_Ptr s)
1843+
{
1844+
return s;
1845+
}
1846+
18501847
// hotfix to avoid invalid nested `:not` selectors
18511848
// probably the wrong place, but this should ultimately
18521849
// be fixed by implement superselector correctly for `:not`
@@ -1878,7 +1875,6 @@ namespace Sass {
18781875
}
18791876
}
18801877
}
1881-
18821878
return s;
18831879
};
18841880

src/eval.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ namespace Sass {
7676
Selector_List_Ptr operator()(Selector_List_Ptr);
7777
Selector_List_Ptr operator()(Complex_Selector_Ptr);
7878
Compound_Selector_Ptr operator()(Compound_Selector_Ptr);
79-
Attribute_Selector_Ptr operator()(Attribute_Selector_Ptr);
80-
// they don't have any specific implementatio (yet)
81-
Element_Selector_Ptr operator()(Element_Selector_Ptr s) { return s; };
82-
Pseudo_Selector_Ptr operator()(Pseudo_Selector_Ptr s) { return s; };
79+
Simple_Selector_Ptr operator()(Simple_Selector_Ptr s);
8380
Wrapped_Selector_Ptr operator()(Wrapped_Selector_Ptr s);
84-
Class_Selector_Ptr operator()(Class_Selector_Ptr s) { return s; };
85-
Id_Selector_Ptr operator()(Id_Selector_Ptr s) { return s; };
86-
Placeholder_Selector_Ptr operator()(Placeholder_Selector_Ptr s) { return s; };
81+
// they don't have any specific implementation (yet)
82+
// Element_Selector_Ptr operator()(Element_Selector_Ptr s) { return s; };
83+
// Pseudo_Selector_Ptr operator()(Pseudo_Selector_Ptr s) { return s; };
84+
// Class_Selector_Ptr operator()(Class_Selector_Ptr s) { return s; };
85+
// Id_Selector_Ptr operator()(Id_Selector_Ptr s) { return s; };
86+
// Placeholder_Selector_Ptr operator()(Placeholder_Selector_Ptr s) { return s; };
8787
// actual evaluated selectors
8888
Selector_List_Ptr operator()(Selector_Schema_Ptr);
8989
Expression_Ptr operator()(Parent_Selector_Ptr);

0 commit comments

Comments
 (0)