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 segfault in at-root cssize edge-case #2439

Merged
merged 1 commit into from
Jul 11, 2017
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
19 changes: 11 additions & 8 deletions src/cssize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ namespace Sass {

Block_Ptr Cssize::operator()(Block_Ptr b)
{
Block_Ptr bb = SASS_MEMORY_NEW(Block, b->pstate(), b->length(), b->is_root());
Block_Obj bb = SASS_MEMORY_NEW(Block, b->pstate(), b->length(), b->is_root());
// bb->tabs(b->tabs());
block_stack.push_back(bb);
append_block(b, bb);
block_stack.pop_back();
return bb;
return bb.detach();
}

Statement_Ptr Cssize::operator()(Trace_Ptr t)
Expand Down Expand Up @@ -259,7 +259,7 @@ namespace Sass {
tmp |= m->exclude_node(s);
}

if (!tmp)
if (!tmp && m->block())
{
Block_Ptr bb = operator()(m->block());
for (size_t i = 0, L = bb->length(); i < L; ++i) {
Expand Down Expand Up @@ -302,14 +302,17 @@ namespace Sass {

Statement_Ptr Cssize::bubble(At_Root_Block_Ptr m)
{
if (!m || !m->block()) return NULL;
Block_Ptr bb = SASS_MEMORY_NEW(Block, this->parent()->pstate());
Has_Block_Obj new_rule = Cast<Has_Block>(SASS_MEMORY_COPY(this->parent()));
new_rule->block(bb);
new_rule->tabs(this->parent()->tabs());
new_rule->block()->concat(m->block());

Block_Ptr wrapper_block = SASS_MEMORY_NEW(Block, m->block()->pstate());
wrapper_block->append(new_rule);
if (new_rule) {
new_rule->block(bb);
new_rule->tabs(this->parent()->tabs());
new_rule->block()->concat(m->block());
wrapper_block->append(new_rule);
}

At_Root_Block_Ptr mm = SASS_MEMORY_NEW(At_Root_Block,
m->pstate(),
wrapper_block,
Expand Down
16 changes: 9 additions & 7 deletions src/inspect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ namespace Sass {
append_token("@at-root ", at_root_block);
append_mandatory_space();
if(at_root_block->expression()) at_root_block->expression()->perform(this);
at_root_block->block()->perform(this);
if(at_root_block->block()) at_root_block->block()->perform(this);
}

void Inspect::operator()(Directive_Ptr at_rule)
Expand Down Expand Up @@ -820,13 +820,15 @@ namespace Sass {

void Inspect::operator()(At_Root_Query_Ptr ae)
{
append_string("(");
ae->feature()->perform(this);
if (ae->value()) {
append_colon_separator();
ae->value()->perform(this);
if (ae->feature()) {
append_string("(");
ae->feature()->perform(this);
if (ae->value()) {
append_colon_separator();
ae->value()->perform(this);
}
append_string(")");
}
append_string(")");
}

void Inspect::operator()(Function_Ptr f)
Expand Down