Skip to content

Commit 1169c76

Browse files
authored
Merge pull request #310 from visitorckw/fix-eof-crash
Fix a crash when reporting an error at the end of a file
2 parents 4da0b6e + 2412df4 commit 1169c76

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/globals.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1395,7 +1395,8 @@ void error(char *msg)
13951395
start_idx = offset + 1;
13961396

13971397
for (offset = 0;
1398-
offset < MAX_SOURCE && SOURCE->elements[start_idx + offset] != '\n';
1398+
offset < MAX_SOURCE && (start_idx + offset) < SOURCE->size &&
1399+
SOURCE->elements[start_idx + offset] != '\n';
13991400
offset++) {
14001401
diagnostic[i++] = SOURCE->elements[start_idx + offset];
14011402
}

0 commit comments

Comments
 (0)