X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=pb_decode.c;h=fba8f64ca745c99e3816f2a68aea52bebc9f0963;hb=5f3bf35e01a0eb5d7c31949bcd32265be056ed5c;hp=bc6df7b978a138cd8026ba30fb5338bb5d71df63;hpb=5442e690f65fd09e7a44437da02fb7e14af6fe8f;p=apps%2Fagl-service-can-low-level.git diff --git a/pb_decode.c b/pb_decode.c index bc6df7b9..fba8f64c 100644 --- a/pb_decode.c +++ b/pb_decode.c @@ -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 */