Skip to content

minor refactor: fix read(char[], int, int) loop bound in LineColumnReader#2406

Closed
cuiweixie wants to merge 1 commit into
apache:masterfrom
cuiweixie:fix/line-column-reader-read-bounds
Closed

minor refactor: fix read(char[], int, int) loop bound in LineColumnReader#2406
cuiweixie wants to merge 1 commit into
apache:masterfrom
cuiweixie:fix/line-column-reader-read-bounds

Conversation

@cuiweixie

Copy link
Copy Markdown
Contributor

Summary

Correct the loop upper bound in LineColumnReader.read(char[], int, int) from i <= startOffset + length to i < startOffset + length.

Rationale

The method should read at most length characters into the slice [startOffset, startOffset + length), consistent with BufferedReader semantics. The previous bound could process one character past that range.

…ader

Use i < startOffset + length instead of i <= startOffset + length so the
method reads at most length characters into the destination slice, matching
BufferedReader semantics and avoiding an off-by-one past the requested range.
@paulk-asert

Copy link
Copy Markdown
Contributor

It looks like JsonLexer usage makes assumptions about the old behavior.

@paulk-asert

Copy link
Copy Markdown
Contributor

Actually, the read(char[] chars) method had a bug which cancels out the previous one. But it makes sense to correct both. Let me take a look.

@paulk-asert

paulk-asert commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Merged with an additional fix. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants