Skip to content

Commit 994695c

Browse files
committed
Fix out of boundary vector access
Fixes #3001
1 parent d2390e5 commit 994695c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/parser_selectors.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,12 @@ namespace Sass {
140140
// parent selector only allowed at start
141141
// upcoming Sass may allow also trailing
142142
ParserState state(pstate);
143-
SimpleSelectorObj prev = (*seq)[seq->length()-1];
144-
std::string sel(prev->to_string({ NESTED, 5 }));
145143
std::string found("&");
146-
if (lex < identifier >()) { found += std::string(lexed); }
144+
if (lex < identifier >()) {
145+
found += std::string(lexed);
146+
}
147+
std::string sel(seq->hasRealParent() ? "&" : "");
148+
if (!seq->empty()) { sel = seq->last()->to_string({ NESTED, 5 }); }
147149
// ToDo: parser should throw parser exceptions
148150
error("Invalid CSS after \"" + sel + "\": expected \"{\", was \"" + found + "\"\n\n"
149151
"\"" + found + "\" may only be used at the beginning of a compound selector.", state);

0 commit comments

Comments
 (0)