You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Change between Node 6.3.1 and 6.4 regarding writing strings of length 0 to a Buffer #8127
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.
This seems like a real bug introduced by 46f40cf, even if this is an edge case. On a first look, it seems like changing >= to > is the correct fix for this.
The fix should land in the next day or two and will go out in the next patch release. Shouldn't take too long. In the meantime, you can apply the patch in #8154 to work around it.
Activity
addaleax commentedon Aug 16, 2016
This seems like a real bug introduced by 46f40cf, even if this is an edge case. On a first look, it seems like changing
>=to>is the correct fix for this.jasnell commentedon Aug 16, 2016
Ugh. Yep, confirmed. Need to add a regression test that covers this also.
buffer: allow .write() offset to be at buffer end
fubar commentedon Aug 18, 2016
Ran into the same issue with node-mysql2, glad it has been identified already.
jasnell commentedon Aug 18, 2016
The fix should land in the next day or two and will go out in the next patch release. Shouldn't take too long. In the meantime, you can apply the patch in #8154 to work around it.
Fix CI builds
mathiasbynens commentedon Aug 22, 2016
Got hit by this as well. Hopefully v6.4.1 can be released soon!
RReverser commentedon Aug 24, 2016
@mathiasbynens Looks like it's fixed only on master, not backported to
v6.x(yet?).evanlucas commentedon Aug 24, 2016
I've been working on getting the commits cherry-picked over to v6.x. Hopefully, will be able to get a release proposal up soon
buffer: allow .write() offset to be at buffer end
Fix CI builds
Pin builds to Node.js 6.3.x
Fix CI builds
Pin builds to Node.js 6.3.x
buffer: allow .write() offset to be at buffer end