Skip to content

Commit

Permalink
Merge pull request sass#3027 from mgreter/bugfix/misc-segfaults
Browse files Browse the repository at this point in the history
Fix a few segfaults
  • Loading branch information
mgreter authored Nov 3, 2019
2 parents 081bbbf + 0b721e0 commit e1c16e0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
8 changes: 6 additions & 2 deletions src/ast_sel_weave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,8 +576,12 @@ namespace Sass {
// Prepare data structures
choices.push_back(expanded);
choices.push_back({ group });
groups1.erase(groups1.begin());
groups2.erase(groups2.begin());
if (!groups1.empty()) {
groups1.erase(groups1.begin());
}
if (!groups2.empty()) {
groups2.erase(groups2.begin());
}

}

Expand Down
8 changes: 4 additions & 4 deletions src/eval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,9 +690,9 @@ namespace Sass {
b->op(), s_l->last(), b->right());
bin_ex->is_delayed(b->left()->is_delayed() || b->right()->is_delayed()); // unverified
for (size_t i = 0; i < s_l->length() - 1; ++i) {
ret_schema->append(Cast<PreValue>(s_l->at(i)->perform(this)));
ret_schema->append(s_l->at(i)->perform(this));
}
ret_schema->append(Cast<PreValue>(bin_ex->perform(this)));
ret_schema->append(bin_ex->perform(this));
return ret_schema->perform(this);
}
}
Expand All @@ -703,9 +703,9 @@ namespace Sass {
Binary_Expression_Obj bin_ex = SASS_MEMORY_NEW(Binary_Expression, b->pstate(),
b->op(), b->left(), s_r->first());
bin_ex->is_delayed(b->left()->is_delayed() || b->right()->is_delayed()); // verified
ret_schema->append(Cast<PreValue>(bin_ex->perform(this)));
ret_schema->append(bin_ex->perform(this));
for (size_t i = 1; i < s_r->length(); ++i) {
ret_schema->append(Cast<PreValue>(s_r->at(i)->perform(this)));
ret_schema->append(s_r->at(i)->perform(this));
}
return ret_schema->perform(this);
}
Expand Down
8 changes: 5 additions & 3 deletions src/parser_selectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,12 @@ namespace Sass {
// parent selector only allowed at start
// upcoming Sass may allow also trailing
ParserState state(pstate);
SimpleSelectorObj prev = (*seq)[seq->length()-1];
std::string sel(prev->to_string({ NESTED, 5 }));
std::string found("&");
if (lex < identifier >()) { found += std::string(lexed); }
if (lex < identifier >()) {
found += std::string(lexed);
}
std::string sel(seq->hasRealParent() ? "&" : "");
if (!seq->empty()) { sel = seq->last()->to_string({ NESTED, 5 }); }
// ToDo: parser should throw parser exceptions
error("Invalid CSS after \"" + sel + "\": expected \"{\", was \"" + found + "\"\n\n"
"\"" + found + "\" may only be used at the beginning of a compound selector.", state);
Expand Down

0 comments on commit e1c16e0

Please sign in to comment.