Switch alltypes.proto to use the new .options file mechanism.
[apps/agl-service-can-low-level.git] / pb_decode.c
index bc6df7b..fba8f64 100644 (file)
@@ -312,6 +312,9 @@ static bool pb_field_next(pb_field_iterator_t *iter)
     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)
@@ -571,7 +574,7 @@ bool checkreturn pb_decode_noinit(pb_istream_t *stream, const pb_field_t fields[
         } 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 */