Skip to content

Commit

Permalink
Only ignore reproducible gain map errors
Browse files Browse the repository at this point in the history
Out-of-memory problems should still be propagated to the user.

Also clear any diagnostic message in case an error is returned later
without setting data->diag (thus returning the wrong message).
  • Loading branch information
y-guyon committed Sep 12, 2023
1 parent 677d26f commit a88dd05
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -4642,6 +4642,12 @@ avifResult avifDecoderReset(avifDecoder * decoder)
if (decoder->ignoreGainMap) {
// When ignoring the gain map, we still report whether one is present or not,
// but do not fail if there was any error with the gain map.
if (findGainMapResult != AVIF_RESULT_OK) {
// Only ignore reproducible errors (caused by the bitstream and not by the environment).
AVIF_CHECKERR(findGainMapResult != AVIF_RESULT_OUT_OF_MEMORY, findGainMapResult);
// Clear diagnostic message.
avifDiagnosticsClearError(data->diag);
}
decoder->gainMapPresent = (findGainMapResult == AVIF_RESULT_OK) && (gainMapItem != NULL);
// We also ignore the actual item and don't decode it.
gainMapItem = NULL;
Expand Down

0 comments on commit a88dd05

Please sign in to comment.