Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a few segfaults #3027

Merged
merged 3 commits into from
Nov 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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