diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 363833ccf47..a26564ded9d 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -327,7 +327,7 @@ Handle Buffer::Base64Slice(const Arguments &args) { int out_len = (n + 2 - ((n + 2) % 3)) / 3 * 4; char *out = new char[out_len]; - char bitbuf[3]; + uint8_t bitbuf[3]; int i = start; // data() index int j = 0; // out index char c; diff --git a/test/simple/test-buffer.js b/test/simple/test-buffer.js index c9228cb5011..2386d10fa43 100644 --- a/test/simple/test-buffer.js +++ b/test/simple/test-buffer.js @@ -306,3 +306,11 @@ assert.equal(new Buffer('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw', 'base64 assert.equal(new Buffer('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg==', 'base64').length, 31); assert.equal(new Buffer('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg=', 'base64').length, 31); assert.equal(new Buffer('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg', 'base64').length, 31); + +// This string encodes single '.' character in UTF-16 +dot = new Buffer('//4uAA==', 'base64'); +assert.equal(dot[0], 0xff); +assert.equal(dot[1], 0xfe); +assert.equal(dot[2], 0x2e); +assert.equal(dot[3], 0x00); +assert.equal(dot.toString('base64'), '//4uAA==');