aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2021-07-15 09:23:59 +0200
committerGitHub <noreply@github.com>2021-07-15 09:23:59 +0200
commit77d5b37da3f1b59e43862c196924d9cf23cd56e2 (patch)
treef8c911e288f850ceeb878904b0ee0444606f304d /src/libexpr
parentbee71d692a10c9fcdc78f589945b9710f676cefb (diff)
parent99f8fc995b2f080cc0a6fe934c8d9c777edc3751 (diff)
Merge pull request #5011 from Pamplemousse/fix_adjustLoc
libexpr: Fix read out-of-bound on the heap
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/lexer.l6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/libexpr/lexer.l b/src/libexpr/lexer.l
index 7298419d9..27975dc9e 100644
--- a/src/libexpr/lexer.l
+++ b/src/libexpr/lexer.l
@@ -38,11 +38,13 @@ static void adjustLoc(YYLTYPE * loc, const char * s, size_t len)
loc->first_line = loc->last_line;
loc->first_column = loc->last_column;
- while (len--) {
+ for (size_t i = 0; i < len; i++) {
switch (*s++) {
case '\r':
- if (*s == '\n') /* cr/lf */
+ if (*s == '\n') { /* cr/lf */
+ i++;
s++;
+ }
/* fall through */
case '\n':
++loc->last_line;