Skip to content

Fix _finishLongTextAscii returning negative remaining length#687

Merged
cowtowncoder merged 3 commits intoFasterXML:2.21from
hisener:halil.sener/gh-issue-686
Apr 9, 2026
Merged

Fix _finishLongTextAscii returning negative remaining length#687
cowtowncoder merged 3 commits intoFasterXML:2.21from
hisener:halil.sener/gh-issue-686

Conversation

@hisener
Copy link
Copy Markdown
Contributor

@hisener hisener commented Apr 7, 2026

return len - outPtr was wrong when outPtr accumulated across multiple outer-loop iterations: len had already been decremented for previous iterations, so subtracting the full outPtr produced a negative value, causing _finishLongText to skip decoding the non-ASCII byte.

Fix: use return len - _inputPtr, which holds only the bytes consumed in the current iteration.

Fixes #686.

@cowtowncoder
Copy link
Copy Markdown
Member

Ok, I think fix needs to against branch 2.21 since 2.18 and 2.21 are 2.x LTS versions and (2.18.x works).
I can merge forward from 2.x to 3.x but not vice versa.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

🧪 Code Coverage Report

Coverage Type Coverage Change
📝 Instructions 76.12% = 0.00%
🔀 Branches 67.00% = 0.00%

@cowtowncoder
Copy link
Copy Markdown
Member

Aside from re-creating PR against 2.21, one process thing is that unless you have already sent it,
we'd need CLA (https://github.com/FasterXML/jackson/blob/main/CLA-jackson-2026.pdf).
This only needs to be sent once, and the usual way is to print it, fill & sign, scan/photo, email to cla at fasterxml dot com.

Once we have it, I can proceed with merging & CLA is good for all future contributions.

Thank you again -- looking forward to merging the fix!

@cowtowncoder cowtowncoder added the cla-needed PR looks good (although may also require code review), but CLA needed from submitter label Apr 8, 2026
`return len - outPtr` was wrong when `outPtr` accumulated across multiple
outer-loop iterations: `len` had already been decremented for previous
iterations, so subtracting the full `outPtr` produced a negative value,
causing `_finishLongText` to skip decoding the non-ASCII byte.

Fix: use `return len - _inputPtr`, which holds only the bytes consumed
in the current iteration.
@hisener hisener force-pushed the halil.sener/gh-issue-686 branch from e020aa5 to def2272 Compare April 8, 2026 07:32
@hisener hisener changed the base branch from 3.x to 2.21 April 8, 2026 07:32
@hisener
Copy link
Copy Markdown
Contributor Author

hisener commented Apr 8, 2026

Addressed the comment and rebased onto 2.21. Also sent the CLA email.

@cowtowncoder cowtowncoder added cla-received Marker to denote that there is a CLA for pr and removed cla-needed PR looks good (although may also require code review), but CLA needed from submitter labels Apr 9, 2026
@cowtowncoder cowtowncoder added this to the 2.21.3 milestone Apr 9, 2026
@cowtowncoder cowtowncoder merged commit b1c1102 into FasterXML:2.21 Apr 9, 2026
@cowtowncoder
Copy link
Copy Markdown
Member

Thank you, @hisener ! Fix merged in, will be in 2.21.3 and 3.1.2.

@hisener hisener deleted the halil.sener/gh-issue-686 branch April 9, 2026 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cbor cla-received Marker to denote that there is a CLA for pr

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CBORParser._finishLongTextAscii returns negative length when TextBuffer segment > I/O buffer, leaving non-ASCII byte unconsumed

2 participants