Open LiamKarlMitchell opened 7 years ago
we should never silently zero-fill, and neither should we do whatever it is we do right now.
What should happen is, if we don't write sizeOf(type) bytes in the write function, we should blow up hard. This should probably be added in the general write
logic, because it's not specific to array or anything.
If you have an array with a fixed number for the count.
And you serialize less elements than the count.
Then the buffer should probably zero fill to look like this.
<Buffer 01 00 00 00 02 00 00 00 00 00 00 00>
Or have an error.Currently it looks like this.
<Buffer 01 00 00 00 02 00 00 00>
Yet if I go over 3 values like so.
It actually over-flows the space in which I would expect it to be allowed to write in.
<Buffer 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00>
Then the parsing would be wrong, because the extra data would not be for the same packet.
I guess this is really two concerns. 1) Undefined to be 00 filled if count length is fixed number. (An option maybe to zero fill or error?) 2) Over-writing past count to throw an error? (Silent ignore could also be a thing maybe an option?)