unittests, change to PB_LTYPE_BYTES data size

git-svn-id: https://svn.kapsi.fi/jpa/nanopb@959 e3a754e5-d11d-0410-8d38-ebb782a927b9
This commit is contained in:
Petteri Aimonen
2011-08-22 18:57:23 +00:00
parent 494fbd91e4
commit 5a9f85b876
6 changed files with 77 additions and 18 deletions

View File

@@ -73,7 +73,7 @@ static bool pb_decode_varint32(pb_istream_t *stream, uint32_t *dest)
bool pb_decode_varint(pb_istream_t *stream, uint64_t *dest)
{
uint8_t byte;
int bitpos = 0;
uint8_t bitpos = 0;
*dest = 0;
while (bitpos < 64 && pb_read(stream, &byte, 1))
@@ -460,9 +460,7 @@ bool pb_dec_bytes(pb_istream_t *stream, const pb_field_t *field, void *dest)
return false;
x->size = temp;
/* Note: data_size includes the size of the x.size field, too.
* Calculate actual size starting from offset. */
if (x->size > field->data_size - offsetof(pb_bytes_array_t, bytes))
if (x->size > field->data_size)
return false;
return pb_read(stream, x->bytes, x->size);