From fcf08f47ef8be04340fc1c35bc4f25eec53afe44 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 20 Nov 2026 17:16:57 -0800 Subject: [PATCH] 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. --- crates/image-codecs/src/format.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/image-codecs/src/format.rs b/crates/image-codecs/src/format.rs index 3b651dd5de..219f165147 100644 --- a/crates/image-codecs/src/format.rs +++ b/crates/image-codecs/src/format.rs @@ -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 { let b = bytes; if b.starts_with(b"\x89PNG\r\n\x1a\n") {