From 280ffd8c692cc24199b678f38fc796825d7df4a1 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Sun, 25 Nov 2018 11:57:50 +0000 Subject: [PATCH] Fix crash in `selector-append('.x~~', 'a')` Fixes #2663 --- src/fn_selectors.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/fn_selectors.cpp b/src/fn_selectors.cpp index e2e22e9e5..31388612a 100644 --- a/src/fn_selectors.cpp +++ b/src/fn_selectors.cpp @@ -140,11 +140,13 @@ namespace Sass { // TODO: Add check for namespace stuff - // append any selectors in childSeq's head - parentSeqClone->mutable_last()->head()->concat(base->head()); - - // Set parentSeqClone new tail - parentSeqClone->mutable_last()->tail( base->tail() ); + Complex_Selector_Ptr lastComponent = parentSeqClone->mutable_last(); + if (lastComponent->head() == nullptr) { + std::string msg = "Parent \"" + parentSeqClone->to_string() + "\" is incompatible with \"" + base->to_string() + "\""; + error(msg, pstate, traces); + } + lastComponent->head()->concat(base->head()); + lastComponent->tail(base->tail()); newElements.push_back(parentSeqClone); }