diff options
-rwxr-xr-x | generator/nanopb_generator.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py index 359e1849..42669ace 100755 --- a/generator/nanopb_generator.py +++ b/generator/nanopb_generator.py @@ -649,9 +649,14 @@ class Field: if self.rules == 'REPEATED': # Decoders must be always able to handle unpacked arrays. # Therefore we have to reserve space for it, even though - # we emit packed arrays ourselves. + # we emit packed arrays ourselves. For length of 1, packed + # arrays are larger however so we need to add allowance + # for the length byte. encsize *= self.max_count + if self.max_count == 1: + encsize += 1 + return encsize |