Call avifMetaFindItem() a bit earlier in avifParseItemLocationBox() to avoid a temporary variable
diff --git a/src/read.c b/src/read.c
index 8b7bb05..7bfd874 100644
--- a/src/read.c
+++ b/src/read.c
@@ -1500,7 +1500,6 @@
}
for (uint32_t i = 0; i < itemCount; ++i) {
uint32_t itemID;
- avifBool idatStored = AVIF_FALSE;
if (version < 2) {
CHECK(avifROStreamReadU16(&s, &tmp16)); // unsigned int(16) item_ID;
itemID = tmp16;
@@ -1508,6 +1507,17 @@
CHECK(avifROStreamReadU32(&s, &itemID)); // unsigned int(32) item_ID;
}
+ avifDecoderItem * item = avifMetaFindItem(meta, itemID);
+ if (!item) {
+ avifDiagnosticsPrintf(diag, "Box[iloc] has an invalid item ID [%u]", itemID);
+ return AVIF_FALSE;
+ }
+ if (item->extents.count > 0) {
+ // This item has already been given extents via this iloc box. This is invalid.
+ avifDiagnosticsPrintf(diag, "Item ID [%u] contains duplicate sets of extents", itemID);
+ return AVIF_FALSE;
+ }
+
if ((version == 1) || (version == 2)) {
uint8_t ignored;
uint8_t constructionMethod;
@@ -1520,22 +1530,10 @@
return AVIF_FALSE;
}
if (constructionMethod == 1) {
- idatStored = AVIF_TRUE;
+ item->idatStored = AVIF_TRUE;
}
}
- avifDecoderItem * item = avifMetaFindItem(meta, itemID);
- if (!item) {
- avifDiagnosticsPrintf(diag, "Box[iloc] has an invalid item ID [%u]", itemID);
- return AVIF_FALSE;
- }
- if (item->extents.count > 0) {
- // This item has already been given extents via this iloc box. This is invalid.
- avifDiagnosticsPrintf(diag, "Item ID [%u] contains duplicate sets of extents", itemID);
- return AVIF_FALSE;
- }
- item->idatStored = idatStored;
-
uint16_t dataReferenceIndex; // unsigned int(16) data_ref rence_index;
CHECK(avifROStreamReadU16(&s, &dataReferenceIndex)); //
uint64_t baseOffset; // unsigned int(base_offset_size*8) base_offset;