Skip to content

[bug] decode throws RangeError on empty Uint8Array #198

@mrl5

Description

@mrl5

decode() throws RangeError on empty Uint8Array

steps to reproduce

const { decode } = require("@msgpack/msgpack");

decode(new Uint8Array());

expected result

hmm hard to tell, maybe null or undefined.

decode(encode());

returns null

actual result

Uncaught RangeError: Offset is outside the bounds of the DataView
    at DataView.getUint8 (<anonymous>)
    at Decoder.readU8 (/home/kuba/tmp_/node_modules/@msgpack/msgpack/dist/Decoder.js:532:33)
    at Decoder.readHeadByte (/home/kuba/tmp_/node_modules/@msgpack/msgpack/dist/Decoder.js:425:34)
    at Decoder.doDecodeSync (/home/kuba/tmp_/node_modules/@msgpack/msgpack/dist/Decoder.js:169:35)
    at Decoder.decode (/home/kuba/tmp_/node_modules/@msgpack/msgpack/dist/Decoder.js:89:29)
    at decode (/home/kuba/tmp_/node_modules/@msgpack/msgpack/dist/decode.js:14:20)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions