Skip to content

Commit

Permalink
Further cleanup in avifParseSampleDescriptionBox()
Browse files Browse the repository at this point in the history
Rename the `remainingBytes` variable as `sampleEntryBytes`. The
`remainingBytes` name made sense when the variable stored the return
value of avifROStreamRemainingBytes(&s). The variable now stores the
value of sampleEntryHeader.size, so the name `sampleEntryBytes` is more
appropriate.

Remove an extraneous pair of parentheses around a conditional
expression.

Replace an instance of sampleEntryHeader.size with `sampleEntryBytes`.
  • Loading branch information
wantehchang authored May 2, 2024
1 parent 4c7f0f4 commit 7be0c35
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -3259,20 +3259,20 @@ static avifResult avifParseSampleDescriptionBox(avifSampleTable * sampleTable,
return AVIF_RESULT_OUT_OF_MEMORY;
}
memcpy(description->format, sampleEntryHeader.type, sizeof(description->format));
size_t remainingBytes = sampleEntryHeader.size;
if ((avifGetCodecType(description->format) != AVIF_CODEC_TYPE_UNKNOWN)) {
if (remainingBytes < VISUALSAMPLEENTRY_SIZE) {
const size_t sampleEntryBytes = sampleEntryHeader.size;
if (avifGetCodecType(description->format) != AVIF_CODEC_TYPE_UNKNOWN) {
if (sampleEntryBytes < VISUALSAMPLEENTRY_SIZE) {
avifDiagnosticsPrintf(diag, "Not enough bytes to parse VisualSampleEntry");
return AVIF_RESULT_BMFF_PARSE_FAILED;
}
AVIF_CHECKRES(avifParseItemPropertyContainerBox(&description->properties,
rawOffset + avifROStreamOffset(&s) + VISUALSAMPLEENTRY_SIZE,
avifROStreamCurrent(&s) + VISUALSAMPLEENTRY_SIZE,
remainingBytes - VISUALSAMPLEENTRY_SIZE,
sampleEntryBytes - VISUALSAMPLEENTRY_SIZE,
diag));
}

AVIF_CHECKERR(avifROStreamSkip(&s, sampleEntryHeader.size), AVIF_RESULT_BMFF_PARSE_FAILED);
AVIF_CHECKERR(avifROStreamSkip(&s, sampleEntryBytes), AVIF_RESULT_BMFF_PARSE_FAILED);
}
return AVIF_RESULT_OK;
}
Expand Down

0 comments on commit 7be0c35

Please sign in to comment.