Skip to content

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

Closed
@niicojs

Description

@niicojs

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions