Fix additional bug with empty message types.
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>
Sat, 9 Mar 2013 11:12:09 +0000 (13:12 +0200)
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>
Sat, 9 Mar 2013 11:12:09 +0000 (13:12 +0200)
pb_field_next() would access past the fields array.

pb_decode.c

index e2e89a0..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)