-
-
Notifications
You must be signed in to change notification settings - Fork 71
Open
Description
The following snippet fails with error at decode:
let buffer = fs.readFileSync('some_large_file');
buffer = buffer.slice(0, 16377);
let object = {
a: buffer,
b: 1
};
let encoded = cbor.encode(object);
let decoded = cbor.decode(encoded);Error: Insufficient data
at Object.decodeFirstSync (/*****/node_modules/cbor/lib/decoder.js:131:15)
at /******/index.js:24:24
at Object.<anonymous> (/*****/index.js:181:1)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:456:32)
at tryModuleLoad (module.js:415:12)
at Function.Module._load (module.js:407:3)
at Function.Module.runMain (module.js:575:10)
at startup (node.js:159:18)
The size of buffer for which the error occurs depends on the name of the object properties a and b. That is, if the names are longer then shorter buffers produce the error.
With property names a and b, the error does not occur if I reduce the size of buffer to 16376 bytes, like:
buffer = buffer.slice(0, 16376);The error does not occur if I switch the order of a and b in object, like:
let object = {
b: 1,
a: buffer
};Reproduced with 2.0.0 and 3.0.0
tri2820luelista and tri2820
Metadata
Metadata
Assignees
Labels
No labels