mlot / nanopb

Automatically exported from code.google.com/p/nanopb
zlib License
0 stars 0 forks source link

Message with no fields in .proto cannot be decoded #65

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Write .proto file which includes a message with no fields.
2. Compile the .proto file.
3. Attempt to decode any stream using that no-fields message.

The result: a "missing required field" error always occurs, even though the 
no-fields message doesn't have any required fields.

Here is a possible patch:
--- nanopb/pb_decode_old.c      2013-03-09 20:57:41 +1100
+++ nanopb/pb_decode_new.c      2013-03-09 20:58:16 +1100
@@ -571,7 +571,7 @@
         } 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 */

Original issue reported on code.google.com by someon...@gmail.com on 9 Mar 2013 at 10:08

GoogleCodeExporter commented 9 years ago
This issue was updated by revision d2e3c1ad930e.

Original comment by Petteri.Aimonen on 9 Mar 2013 at 10:37

GoogleCodeExporter commented 9 years ago
Fix released in 0.2.1

Original comment by Petteri.Aimonen on 14 Apr 2013 at 7:19