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

Empty buffer with "repeated byte" lead to exception #885

Closed
niicojs opened this issue Aug 1, 2017 · 1 comment · Fixed by #1514
Closed

Empty buffer with "repeated byte" lead to exception #885

niicojs opened this issue Aug 1, 2017 · 1 comment · Fixed by #1514

Comments

@niicojs
Copy link

niicojs commented Aug 1, 2017

protobuf.js version: 6.8.0

Using an empty buffer with Message.fromObject leads to exception on compiled JS.

Message.fromObject({ bytesarray: [ Buffer.alloc(0) ] })
TypeError: Cannot read property 'length' of undefined
    at BufferWriter.write_bytes_buffer [as bytes] (c:\Users\nico\Documents\GitHub\sandbox\node_modules\protobufjs\src\writer_buffer.js:50:20)
    at Function.encode (c:\Users\nico\Documents\GitHub\sandbox\node_modules\node-pogo-protos-vnext\compiled.js:53810:77)
    at testEncode (c:\Users\nico\Documents\GitHub\sandbox\index.js:48:22)
    at Object.<anonymous> (c:\Users\nico\Documents\GitHub\sandbox\index.js:51:1)
    at Module._compile (module.js:566:14)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)
    at bootstrap_node.js:575:3
@niicojs
Copy link
Author

niicojs commented Aug 1, 2017

Actually the error stack may not be accurate. The thing is fromObject()convert Buffer.alloc(0) to undefined, which break another part of my code.
I don't think an empty Buffer should be converted with undefined

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

Successfully merging a pull request may close this issue.

1 participant