Skip to content

Commit e1c16e0

Browse files
authored
Merge pull request #3027 from mgreter/bugfix/misc-segfaults
Fix a few segfaults
2 parents 081bbbf + 0b721e0 commit e1c16e0

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

src/ast_sel_weave.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,12 @@ namespace Sass {
576576
// Prepare data structures
577577
choices.push_back(expanded);
578578
choices.push_back({ group });
579-
groups1.erase(groups1.begin());
580-
groups2.erase(groups2.begin());
579+
if (!groups1.empty()) {
580+
groups1.erase(groups1.begin());
581+
}
582+
if (!groups2.empty()) {
583+
groups2.erase(groups2.begin());
584+
}
581585

582586
}
583587

src/eval.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -690,9 +690,9 @@ namespace Sass {
690690
b->op(), s_l->last(), b->right());
691691
bin_ex->is_delayed(b->left()->is_delayed() || b->right()->is_delayed()); // unverified
692692
for (size_t i = 0; i < s_l->length() - 1; ++i) {
693-
ret_schema->append(Cast<PreValue>(s_l->at(i)->perform(this)));
693+
ret_schema->append(s_l->at(i)->perform(this));
694694
}
695-
ret_schema->append(Cast<PreValue>(bin_ex->perform(this)));
695+
ret_schema->append(bin_ex->perform(this));
696696
return ret_schema->perform(this);
697697
}
698698
}
@@ -703,9 +703,9 @@ namespace Sass {
703703
Binary_Expression_Obj bin_ex = SASS_MEMORY_NEW(Binary_Expression, b->pstate(),
704704
b->op(), b->left(), s_r->first());
705705
bin_ex->is_delayed(b->left()->is_delayed() || b->right()->is_delayed()); // verified
706-
ret_schema->append(Cast<PreValue>(bin_ex->perform(this)));
706+
ret_schema->append(bin_ex->perform(this));
707707
for (size_t i = 1; i < s_r->length(); ++i) {
708-
ret_schema->append(Cast<PreValue>(s_r->at(i)->perform(this)));
708+
ret_schema->append(s_r->at(i)->perform(this));
709709
}
710710
return ret_schema->perform(this);
711711
}

src/parser_selectors.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,12 @@ namespace Sass {
140140
// parent selector only allowed at start
141141
// upcoming Sass may allow also trailing
142142
ParserState state(pstate);
143-
SimpleSelectorObj prev = (*seq)[seq->length()-1];
144-
std::string sel(prev->to_string({ NESTED, 5 }));
145143
std::string found("&");
146-
if (lex < identifier >()) { found += std::string(lexed); }
144+
if (lex < identifier >()) {
145+
found += std::string(lexed);
146+
}
147+
std::string sel(seq->hasRealParent() ? "&" : "");
148+
if (!seq->empty()) { sel = seq->last()->to_string({ NESTED, 5 }); }
147149
// ToDo: parser should throw parser exceptions
148150
error("Invalid CSS after \"" + sel + "\": expected \"{\", was \"" + found + "\"\n\n"
149151
"\"" + found + "\" may only be used at the beginning of a compound selector.", state);

0 commit comments

Comments
 (0)