aakash-sahai / nanopb

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

Problem with bytes array with max_size #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
If I declare a field as:                                                        

optional bytes iv=3 [(nanopb).max_size = 16];                                   

the pb_encode() function does not take the size member of the                   

pb_bytes_array_t struct into account when                                       

it updates the pData pointer on line 155-158 in pb_encode.c                     

It is caused by the pb_generator.py line 241-242                                

elif self.htype != 'PB_HTYPE_CALLBACK' and not self.is_pointer and              

self.ltype == 'PB_LTYPE_BYTES':                                                 

result += '\n    pb_membersize(%s, bytes),' % self.ctype                        

only measuring the size of the bytes array and not including the size member.   

I have solved this temporarily by updating the generated field                  

descriptor manually to measure the                                              

size of the whole pb_bytes_array_t struct but I am not sure it has              

other side effects...

Original issue reported on code.google.com by Petteri.Aimonen on 12 Jan 2012 at 9:56

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 113bd7ee878a.

Original comment by Petteri.Aimonen on 12 Jan 2012 at 5:13