Skip to content

Commit

Permalink
avoid decoding when there is an empty chunk
Browse files Browse the repository at this point in the history
Signed-off-by: Kimball Thurston <[email protected]>
  • Loading branch information
kdt3rd committed Sep 19, 2024
1 parent 76c932a commit 04a91b7
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/lib/OpenEXRCore/decoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,9 @@ default_read_chunk (exr_decode_pipeline_t* decode)
decode->unpacked_alloc_size == 0)
decode->unpacked_buffer = NULL;

if (part->storage_mode == EXR_STORAGE_DEEP_SCANLINE ||
part->storage_mode == EXR_STORAGE_DEEP_TILED)
if ((part->storage_mode == EXR_STORAGE_DEEP_SCANLINE ||
part->storage_mode == EXR_STORAGE_DEEP_TILED) &&
decode->chunk.sample_count_table_size > 0)
{
rv = internal_decode_alloc_buffer (
decode,
Expand Down Expand Up @@ -192,7 +193,7 @@ default_read_chunk (exr_decode_pipeline_t* decode)
decode->packed_sample_count_table);
}
}
else
else if (decode->chunk.packed_size > 0)
{
rv = internal_decode_alloc_buffer (
decode,
Expand All @@ -204,6 +205,8 @@ default_read_chunk (exr_decode_pipeline_t* decode)
rv = exr_read_chunk (
ctxt, decode->part_index, &(decode->chunk), decode->packed_buffer);
}
else
rv = EXR_ERR_SUCCESS;

return rv;
}
Expand Down Expand Up @@ -310,6 +313,13 @@ exr_decoding_initialize (
}
}

/* will have already been reported during header parse, but just
* stop the file from being read
*/
if (!part->channels || part->channels->type != EXR_ATTR_CHLIST ||
part->channels->chlist->num_channels <= 0)
return EXR_ERR_INVALID_ATTR;

rv = internal_coding_fill_channel_info (
&(decode->channels),
&(decode->channel_count),
Expand Down

0 comments on commit 04a91b7

Please sign in to comment.