Merge pull request #5011 from Pamplemousse/fix_adjustLoc

libexpr: Fix read out-of-bound on the heap
This commit is contained in:
Eelco Dolstra 2021-07-15 09:23:59 +02:00 committed by GitHub
commit 77d5b37da3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;