Skip to content

Commit 8e681e2

Browse files
glebmxzyfer
authored andcommitted
Fix heap-buffer-overflow in prelexer.hpp:70 (#2857)
Fixes #2814
1 parent d382603 commit 8e681e2

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/prelexer.hpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,15 @@ namespace Sass {
6565
size_t level = 0;
6666
bool in_squote = false;
6767
bool in_dquote = false;
68-
// bool in_braces = false;
69-
70-
while (*src) {
71-
72-
// check for abort condition
73-
if (end && src >= end) break;
68+
bool in_backslash_escape = false;
7469

70+
while ((end == nullptr || src < end) && *src != '\0') {
7571
// has escaped sequence?
76-
if (*src == '\\') {
77-
++ src; // skip this (and next)
72+
if (in_backslash_escape) {
73+
in_backslash_escape = false;
74+
}
75+
else if (*src == '\\') {
76+
in_backslash_escape = true;
7877
}
7978
else if (*src == '"') {
8079
in_dquote = ! in_dquote;
@@ -120,7 +119,7 @@ namespace Sass {
120119
// first start/opener must be consumed already!
121120
template<prelexer start, prelexer stop>
122121
const char* skip_over_scopes(const char* src) {
123-
return skip_over_scopes<start, stop>(src, 0);
122+
return skip_over_scopes<start, stop>(src, nullptr);
124123
}
125124

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

0 commit comments

Comments
 (0)