@@ -1789,11 +1789,28 @@ namespace Sass {
1789
1789
Expression_Obj sel = s->contents ()->perform (this );
1790
1790
std::string result_str (sel->to_string (ctx.c_options ));
1791
1791
result_str = unquote (Util::rtrim (result_str));
1792
- Parser p = Parser::from_c_str (result_str.c_str (), ctx, s->pstate ());
1792
+ char * temp_cstr = sass_copy_c_string (result_str.c_str ());
1793
+ ctx.strings .push_back (temp_cstr); // attach to context
1794
+ Parser p = Parser::from_c_str (temp_cstr, ctx, s->pstate ());
1793
1795
p.last_media_block = s->media_block ();
1794
1796
// a selector schema may or may not connect to parent?
1795
1797
bool chroot = s->connect_parent () == false ;
1796
1798
Selector_List_Obj sl = p.parse_selector_list (chroot);
1799
+ auto vec_str_rend = ctx.strings .rend ();
1800
+ auto vec_str_rbegin = ctx.strings .rbegin ();
1801
+ // remove the first item searching from the back
1802
+ // we cannot assume our item is still the last one
1803
+ // order is not important, so we can optimize this
1804
+ auto it = std::find (vec_str_rbegin, vec_str_rend, temp_cstr);
1805
+ // undefined behavior if not found!
1806
+ if (it != vec_str_rend) {
1807
+ // overwrite with last item
1808
+ *it = ctx.strings .back ();
1809
+ // remove last one from vector
1810
+ ctx.strings .pop_back ();
1811
+ // free temporary copy
1812
+ free (temp_cstr);
1813
+ }
1797
1814
flag_is_in_selector_schema.reset ();
1798
1815
return operator ()(sl);
1799
1816
}
0 commit comments