Skip to content

Buffer write* silently sets 0 instead of failing for wrong values #1161

Description

@unbornchikken

Repro:

> var b = new Buffer(6);
undefined
> b.writeUInt32LE(10, 0);
4
> b.readUInt32LE(0)
10
> b.writeUInt32LE("5", 0);
4
> b.readUInt32LE(0)
5
> b.writeUInt32LE({}, 0);
4
> b.readUInt32LE(0)
0
> b.writeUInt32LE({}, 0, false);
4
> b.readUInt32LE(0)
0

According to this: https://iojs.org/api/buffer.html#buffer_buf_writeint32le_value_offset_noassert, the last three writes should be failed, because value is not a valid integer.

Metadata

Metadata

Assignees

Labels

bufferIssues and PRs related to the buffer subsystem.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions