image-codecs: correct the prefix length that detect documents for FF D8

For a buffer of only `FF D8`, `detect_prefix` answers `NeedBytes(4)`,
a 4-byte prefix that includes the SOI, not 4 bytes after it.
This commit is contained in:
dotCooCoo
2026-11-20 17:16:57 -08:00
parent 32bba41a91
commit fcf08f47ef
+1 -1
View File
@@ -413,7 +413,7 @@ impl PrefixDetector {
/// JPEG-LS is told from JPEG by the frame header that follows the marker segments, so `bytes`
/// must reach that header; a buffer that ends before it is reported as [`Format::Jpeg`] when it
/// starts with `FF D8 FF`, and a buffer of only `FF D8` matches no format. Use [`detect_prefix`] on
/// a buffer that may hold only the start of a file: it asks for 4 bytes after `FF D8`.
/// a buffer that may hold only the start of a file: for `FF D8` it asks for a 4-byte prefix.
pub fn detect(bytes: &[u8]) -> Option<Format> {
let b = bytes;
if b.starts_with(b"\x89PNG\r\n\x1a\n") {