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
var a = new Buffer('1', 'hex') creates a new empty buffer. This throws an error on earlier versions of node (tested on v5.8) as the input length should be a multiple of 1 byte.
Probably introduced by afd821a in lib/buffer.js. The length check returns 0 which would have normally gone on to raise an error at a later stage but is now short circuited by the new code.
Could probably just do with an extra line to check if the input is non empty or have byteLength return a fractional value.
Could probably just do with an extra line to check if the input is non empty
Yeah, I think that’s the right thing to do (maybe even instead of/before the byteLength calculation, as @ronkorving’s comment on afd821a suggests). Interested in writing a PR for that?
Activity
addaleax commentedon May 15, 2016
Yep, can confirm that.
Yeah, I think that’s the right thing to do (maybe even instead of/before the byteLength calculation, as @ronkorving’s comment on afd821a suggests). Interested in writing a PR for that?
/cc @nodejs/buffer
jspri commentedon May 15, 2016
Sure, I'll do a PR. Is this the sort of thing you would normally also write a test case for?
addaleax commentedon May 15, 2016
Yes, definitely. You can see an example of a test for that in e.g. #4877, which comes pretty close to what you are going to test here.
Buffer: Fixes nodejs#6770, Single digit hex strings not raising TypeE…
buffer: fix single digit hex string handling
buffer: fix single digit hex string handling
buffer: fix single digit hex string handling