Increment num_boxes if !ftyp in stream API Change-Id: I22c46d82d967ae7d154e1600ecf6e96c1589a7d6
diff --git a/avifinfo.c b/avifinfo.c index 758130e..a8a0272 100644 --- a/avifinfo.c +++ b/avifinfo.c
@@ -718,6 +718,14 @@ AVIFINFO_CHECK_FOUND(AvifInfoInternalParseBox( /*nesting_level=*/0, stream, AVIFINFO_MAX_SIZE, num_parsed_boxes, &box)); + if (*num_parsed_boxes == 1 && memcmp(box.type, "ftyp", 4)) { + // AvifInfoGetFeaturesStream() can be called on a full stream or on a + // stream where the 'ftyp' box was already read. If it is not the first + // parsed box here, consider it was, so that this function returns the + // same status in both situations (because of the AVIFINFO_MAX_NUM_BOXES + // check that would compare a different box count otherwise). + ++*num_parsed_boxes; + } if (!memcmp(box.type, "meta", 4)) { return ParseMeta(/*nesting_level=*/1, stream, box.content_size, num_parsed_boxes, features);