Skip to content

Commit

Permalink
assert that tile size is not 0
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Sep 16, 2024
1 parent 576f8ba commit b118f04
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions libheif/codecs/uncompressed_image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,9 @@ class AbstractDecoder
{
m_tile_height = m_height / m_uncC->get_number_of_tile_rows();
m_tile_width = m_width / m_uncC->get_number_of_tile_columns();

assert(m_tile_width > 0);
assert(m_tile_height > 0);
}

const uint32_t m_width;
Expand Down Expand Up @@ -880,6 +883,7 @@ class ComponentInterleaveDecoder : public AbstractDecoder
total_tile_size += nAlignmentSkipBytes(m_uncC->get_tile_align_size(), total_tile_size);
}

assert(m_tile_width > 0);
uint32_t tileIdx = tile_x + tile_y * (image_width / m_tile_width);
uint64_t tile_start_offset = total_tile_size * tileIdx;

Expand Down Expand Up @@ -968,6 +972,7 @@ class PixelInterleaveDecoder : public AbstractDecoder
total_tile_size += nAlignmentSkipBytes(m_uncC->get_tile_align_size(), total_tile_size);
}

assert(m_tile_width > 0);
uint32_t tileIdx = tile_x + tile_y * (image_width / m_tile_width);
uint64_t tile_start_offset = total_tile_size * tileIdx;

Expand Down Expand Up @@ -1059,6 +1064,7 @@ class MixedInterleaveDecoder : public AbstractDecoder
tile_size += nAlignmentSkipBytes(m_uncC->get_tile_align_size(), tile_size);
}

assert(m_tile_width > 0);
uint32_t tileIdx = tile_x + tile_y * (image_width / m_tile_width);
uint64_t tile_start_offset = tile_size * tileIdx;

Expand Down Expand Up @@ -1168,6 +1174,7 @@ class RowInterleaveDecoder : public AbstractDecoder
total_tile_size += nAlignmentSkipBytes(m_uncC->get_tile_align_size(), total_tile_size);
}

assert(m_tile_width > 0);
uint32_t tileIdx = tile_x + tile_y * (image_width / m_tile_width);
uint64_t tile_start_offset = total_tile_size * tileIdx;

Expand Down Expand Up @@ -1262,6 +1269,9 @@ class TileComponentInterleaveDecoder : public AbstractDecoder

uint64_t component_start_offset = 0;

assert(m_tile_width > 0);
assert(m_tile_height > 0);

for (ChannelListEntry& entry : channelList) {
//processTile(srcBits, tile_y, tile_x, out_x0, out_y0);

Expand Down

0 comments on commit b118f04

Please sign in to comment.