Skip to content

Change between Node 6.3.1 and 6.4 regarding writing strings of length 0 to a Buffer #8127

Closed
@phretaddin

Description

@phretaddin

In Node 6.3.1, you could do this:

var buff = Buffer.alloc(1);
buff.write('', 1, 0);
console.log(buff);

That is, writing empty strings out of the buffer bounds would not cause a crash. However, with 6.4, that code above causes a crash with this error message:

buffer.js:761
     return this.utf8Write(string, offset, length);

Range Error: Offset is out of bounds

This change causes my library to break. I'm wondering if this was an intentional change. If so, just let me know, and I'll patch my library to check for empty strings before writing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bufferIssues and PRs related to the buffer subsystem.confirmed-bugIssues with confirmed bugs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions