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 heap-buffer-overflow in prelexer.hpp:70 #2857

Merged
merged 1 commit into from
Apr 5, 2019
Merged
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
17 changes: 8 additions & 9 deletions src/prelexer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,15 @@ namespace Sass {
size_t level = 0;
bool in_squote = false;
bool in_dquote = false;
// bool in_braces = false;

while (*src) {

// check for abort condition
if (end && src >= end) break;
bool in_backslash_escape = false;

while ((end == nullptr || src < end) && *src != '\0') {
// has escaped sequence?
if (*src == '\\') {
++ src; // skip this (and next)
if (in_backslash_escape) {
in_backslash_escape = false;
}
else if (*src == '\\') {
in_backslash_escape = true;
}
else if (*src == '"') {
in_dquote = ! in_dquote;
Expand Down Expand Up @@ -120,7 +119,7 @@ namespace Sass {
// first start/opener must be consumed already!
template<prelexer start, prelexer stop>
const char* skip_over_scopes(const char* src) {
return skip_over_scopes<start, stop>(src, 0);
return skip_over_scopes<start, stop>(src, nullptr);
}

// Match a sequence of characters delimited by the supplied chars.
Expand Down