nonregression/issue775.j2k (and issue775-2.j2k, same bytes) has a last tile-part whose Psot ends 4 bytes short of the file end. mercury's SOT walk in plan.rs (draft, the sequential branch) only stops when fewer than 2 bytes remain, so it tries to read a 12-byte SOT at that position and the plan fails with "io: failed to fill whole buffer". the stream falls back to classic, which also fails it ("No tiles were decompressed", the tile COD carries an HT block style), so today nothing is lost.
ending the walk when fewer than 12 bytes remain (or when the bytes there are not an SOT) would let mercury finish the chain and take the stream once HT lands. it also makes the walk tolerate trailing garbage it currently refuses, so the change needs a run over the fuzzer corpus (tests/nonregression clusterfuzz inputs and the mercury fuzzer) before landing, to confirm no stream that used to fall back now mis-decodes.
nonregression/issue775.j2k (and issue775-2.j2k, same bytes) has a last tile-part whose Psot ends 4 bytes short of the file end. mercury's SOT walk in plan.rs (draft, the sequential branch) only stops when fewer than 2 bytes remain, so it tries to read a 12-byte SOT at that position and the plan fails with "io: failed to fill whole buffer". the stream falls back to classic, which also fails it ("No tiles were decompressed", the tile COD carries an HT block style), so today nothing is lost.
ending the walk when fewer than 12 bytes remain (or when the bytes there are not an SOT) would let mercury finish the chain and take the stream once HT lands. it also makes the walk tolerate trailing garbage it currently refuses, so the change needs a run over the fuzzer corpus (tests/nonregression clusterfuzz inputs and the mercury fuzzer) before landing, to confirm no stream that used to fall back now mis-decodes.