sanitize Source.loc argument

This commit is contained in:
2025-01-12 03:10:44 +02:00
parent 24d0cb73b6
commit 3623842827

View File

@@ -12,6 +12,8 @@ public class Source {
private int[] lineStarts; private int[] lineStarts;
public Location loc(int offset) { public Location loc(int offset) {
if (offset < 0) offset = 0;
if (offset > src.length()) offset = src.length();
return new SourceLocation(filename, lineStarts, offset); return new SourceLocation(filename, lineStarts, offset);
} }
public boolean is(int i, char c) { public boolean is(int i, char c) {