Skip to content

Commit

Permalink
Do not store colorproperties until alpha item is found
Browse files Browse the repository at this point in the history
colorProperties could be pointing to a dangling pointer if
findAlphaItem() resizes the meta.items array.
  • Loading branch information
vigneshvg committed Nov 28, 2023
1 parent af93d66 commit 7845153
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -4804,7 +4804,6 @@ avifResult avifDecoderReset(avifDecoder * decoder)
/*isItemInInput=*/AVIF_TRUE,
&data->tileInfos[AVIF_ITEM_COLOR].grid,
&codecType[AVIF_ITEM_COLOR]));
colorProperties = &data->meta->items.item[mainItemIndices[AVIF_ITEM_COLOR]].properties;
colorCodecType = codecType[AVIF_ITEM_COLOR];

// Optional alpha auxiliary item
Expand Down Expand Up @@ -4865,6 +4864,7 @@ avifResult avifDecoderReset(avifDecoder * decoder)
for (int c = 0; c < AVIF_ITEM_CATEGORY_COUNT; ++c) {
mainItems[c] = (mainItemIndices[c] == -1) ? NULL : &data->meta->items.item[mainItemIndices[c]];
}
colorProperties = &mainItems[AVIF_ITEM_COLOR]->properties;

// Find Exif and/or XMP metadata, if any
AVIF_CHECKRES(avifDecoderFindMetadata(decoder, data->meta, decoder->image, mainItems[AVIF_ITEM_COLOR]->id));
Expand Down

0 comments on commit 7845153

Please sign in to comment.