fix queue_types bugs related to adding the length field
I thought I made sure the test still passed, but apparently not...
Change-Id: Iae045a475171c96397d3dcf3ed647c41f2c8a1fd
diff --git a/aos/common/queue_types.cc b/aos/common/queue_types.cc
index f04e365..4dd7d43 100644
--- a/aos/common/queue_types.cc
+++ b/aos/common/queue_types.cc
@@ -90,7 +90,8 @@
for (int i = 0; i < number_fields; ++i) {
uint16_t field_name_length;
- if (*bytes < sizeof(fields[i]->type) + sizeof(field_name_length)) {
+ if (*bytes < sizeof(fields[i]->type) + sizeof(field_name_length) +
+ (deserialize_length ? sizeof(fields[i]->length) : 0)) {
return nullptr;
}
*bytes -= sizeof(fields[i]->type) + sizeof(field_name_length);
@@ -100,6 +101,7 @@
if (deserialize_length) {
to_host(buffer, &fields[i]->length);
buffer += sizeof(fields[i]->length);
+ *bytes -= sizeof(fields[i]->length);
}
to_host(buffer, &field_name_length);
buffer += sizeof(field_name_length);