Looks like if you have a bool in your struct and you're writing using Compact format, it's very likely the resulting message will be corrupt. See attached testcase.
This occurs due to this piece of code -- the "else" clause does not write out the field ID.
def write_bool(self, bool):
if self._bool_fid and self._bool_fid > self._last_fid \
and self._bool_fid - self._last_fid <= 15:
if bool:
ctype = CompactType.TRUE
else:
ctype = CompactType.FALSE
self._write_field_header(ctype, self._bool_fid)
else:
if bool:
self.write_byte(CompactType.TRUE)
else:
self.write_byte(CompactType.FALSE)
In a practical sense, this may occur if the last field ID written out is more than 15 IDs away, but consider this:
- Fields are not necessarily written out in ID order (maybe that's a separate bug?)
- If the previous fields were default values, then they are not written out at all -- thus do not contribute to the ID closeness required to not trigger the else clause.
corrupt_bool_testcase.txt
Looks like if you have a bool in your struct and you're writing using Compact format, it's very likely the resulting message will be corrupt. See attached testcase.
This occurs due to this piece of code -- the "else" clause does not write out the field ID.
In a practical sense, this may occur if the last field ID written out is more than 15 IDs away, but consider this:
corrupt_bool_testcase.txt