From d2390e54c4f1ab5c33a0e35e7b9264b36284fa91 Mon Sep 17 00:00:00 2001 From: Marcel Greter Date: Sun, 3 Nov 2019 00:41:41 +0100 Subject: [PATCH 1/3] Fix nullptr access on interpolated parents Fixes https://github.com/sass/libsass/issues/3024 --- src/eval.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/eval.cpp b/src/eval.cpp index 67f079869..93bce0acc 100644 --- a/src/eval.cpp +++ b/src/eval.cpp @@ -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(s_l->at(i)->perform(this))); + ret_schema->append(s_l->at(i)->perform(this)); } - ret_schema->append(Cast(bin_ex->perform(this))); + ret_schema->append(bin_ex->perform(this)); return ret_schema->perform(this); } } @@ -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(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(s_r->at(i)->perform(this))); + ret_schema->append(s_r->at(i)->perform(this)); } return ret_schema->perform(this); } From 994695c669085058c4a500f295a0531893eff77a Mon Sep 17 00:00:00 2001 From: Marcel Greter Date: Sun, 3 Nov 2019 00:42:10 +0100 Subject: [PATCH 2/3] Fix out of boundary vector access Fixes https://github.com/sass/libsass/issues/3001 --- src/parser_selectors.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/parser_selectors.cpp b/src/parser_selectors.cpp index d76dd2ca7..3b4a6e2d9 100644 --- a/src/parser_selectors.cpp +++ b/src/parser_selectors.cpp @@ -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); From 0b721e0f37fc69ab197ec956a923e036e3b05ca6 Mon Sep 17 00:00:00 2001 From: Marcel Greter Date: Sun, 3 Nov 2019 01:06:18 +0100 Subject: [PATCH 3/3] Fix out of boundary vector access Fixes https://github.com/sass/libsass/issues/2999 --- src/ast_sel_weave.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ast_sel_weave.cpp b/src/ast_sel_weave.cpp index 2785ea370..c792d0f8a 100644 --- a/src/ast_sel_weave.cpp +++ b/src/ast_sel_weave.cpp @@ -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()); + } }