Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array not enough elements or too much elements. #80

Open
LiamKarlMitchell opened this issue Jun 23, 2017 · 1 comment
Open

Array not enough elements or too much elements. #80

LiamKarlMitchell opened this issue Jun 23, 2017 · 1 comment

Comments

@LiamKarlMitchell
Copy link

If you have an array with a fixed number for the count.

{
  "name": "numbers",
  "type": [
    "array",
    {
      "count": 3,
      "type": "li32"
    }
  ]
}

And you serialize less elements than the count.

  { "numbers": [1,2] }

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.

  { "numbers": [1,2,3,4] }

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?)
@roblabla
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants