Skip to content

Parse entropy-coded data in jpg example - #311

Merged
keichi merged 1 commit into
masterfrom
fix-jpg-example
Oct 15, 2026
Merged

keichi merged 1 commit into
masterfrom
fix-jpg-example

Conversation

@keichi

@keichi keichi commented Oct 15, 2026

Copy link
Copy Markdown
Owner

The entropy-coded scan data following an SOS segment was parsed as another segment. This yielded a bogus marker (0xFA89) with a length of 18931 for a 2047-byte file, seeked past the end of the file, and never reached EOI.

Read the scan data into a data buffer up to the next marker (any 0xFFxx other than the stuffed 0xFF00 and the RSTn markers). The segments are now SOI, APP0, APP12, APP14, DQT, SOF2, DHT, 10 × SOS, and EOI.

The scan data following an SOS segment was parsed as another segment,
which yielded a bogus marker and seeked past the end of the file. Read
it into a buffer up to the next marker so that following segments,
including EOI, are parsed correctly.
@keichi
keichi merged commit 1ec87fa into master Oct 15, 2026
8 checks passed
@keichi
keichi deleted the fix-jpg-example branch October 15, 2026 14:38
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.

1 participant