瀏覽代碼

LibGfx/JPEG2000: Fix off-by-one in reading comment data 😬

For text, we always ended up with a leading \0 byte (on little-endian),
which prints as nothing. Since that's the only thing we do with this
data, no actual behavior change.
Nico Weber 1 年之前
父節點
當前提交
2c9c996130
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      Userland/Libraries/LibGfx/ImageFormats/JPEG2000Loader.cpp

+ 1 - 1
Userland/Libraries/LibGfx/ImageFormats/JPEG2000Loader.cpp

@@ -453,7 +453,7 @@ static ErrorOr<Comment> read_comment(ReadonlyBytes data)
     if (comment_type > 1)
         return Error::from_string_literal("JPEG2000ImageDecoderPlugin: Invalid comment type");
     com.type = static_cast<Comment::CommentType>(comment_type);
-    com.data = data.slice(1);
+    com.data = data.slice(2);
 
     dbgln_if(JPEG2000_DEBUG, "JPEG2000ImageDecoderPlugin: COM marker segment: comment_type={}, size()={}", (int)com.type, com.data.size());
     if (com.type == Comment::ISO_IEC_8859_15)