Skip to content

Commit

Permalink
LibGfx/TIFF: Also seek after reading the last tag
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
LucasChollet authored and ADKaster committed Feb 8, 2024
1 parent a43793e commit 42f29b9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,14 +498,14 @@ class TIFFLoadingContext {
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);

// Section 2: TIFF Structure
// 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());
Expand Down

0 comments on commit 42f29b9

Please sign in to comment.