From 42f29b96706a6cddcb4744493ab4361a0d562b2b Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Sat, 3 Feb 2024 16:35:31 -0500 Subject: [PATCH] LibGfx/TIFF: Also seek after reading the last tag The `read_tag()` function is not mandated to keep the reading head at a meaningful position, so we also need to align the pointer after the last tag. This solves a bug where reading the last field of an IFD, which is placed after the tags, was incorrect. --- Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp b/Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp index 9eecea584e..6076fb8875 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp @@ -498,7 +498,6 @@ private: auto next_tag_offset = TRY(m_stream->tell()); for (u16 i = 0; i < number_of_field; ++i) { - TRY(m_stream->seek(next_tag_offset)); if (auto maybe_error = read_tag(); maybe_error.is_error() && TIFF_DEBUG) dbgln("Unable to decode tag {}/{}", i + 1, number_of_field); @@ -506,6 +505,7 @@ private: // IFD Entry // Size of tag(u16) + type(u16) + count(u32) + value_or_offset(u32) = 12 next_tag_offset += 12; + TRY(m_stream->seek(next_tag_offset)); } TRY(read_next_idf_offset());