diff options
author | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2017-03-28 23:20:31 +0300 |
---|---|---|
committer | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2017-03-28 23:20:31 +0300 |
commit | 25210ac1419567178502e99f005ddb49c4e63d21 (patch) | |
tree | dd20a90e9bfd33987d2eb18cd98a9c3ab081d3d3 | |
parent | d56c4cc79bdc85433e8cb592a67e51997d5d6f50 (diff) |
Fix message length calculation for arrays of size 1 (issue #253)
-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 |