if (PB_HTYPE(iter->current->type) == PB_HTYPE_REQUIRED)
iter->required_field_index++;
+ if (iter->current->tag == 0)
+ return false; /* Only happens with empty message types */
+
iter->current++;
iter->field_index++;
if (iter->current->tag == 0)
} while (pb_field_next(&iter));
/* Fixup if last field was also required. */
- if (PB_HTYPE(last_type) == PB_HTYPE_REQUIRED)
+ if (PB_HTYPE(last_type) == PB_HTYPE_REQUIRED && iter.current->tag)
req_field_count++;
/* Check the whole bytes */