buffer: let WriteFloatGeneric silently drop values

Documentation currently states that setting noAssert and passing a value
larger than can fit in the Buffer will cause data to be silently
dropped. Change implementation to match documented behavior.

Fixes: https://github.com/nodejs/node/issues/3766
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
This commit is contained in:
P.S.V.R authored and James M Snell committed 2015-12-23 08:38:33 -08:00
1 parent 04d8a654b2
commit edcb6c0603
2 files changed
+12 -3

No files matched your search

+7
View File
@@ -44,3 +44,10 @@ assert.throws(function() {
AB.prototype.__proto__ = ArrayBuffer.prototype;
new Buffer(new AB());
}, TypeError);
// write{Double,Float}{LE,BE} with noAssert should not crash, cf. #3766
var b = new Buffer(1);
b.writeFloatLE(11.11, 0, true);
b.writeFloatBE(11.11, 0, true);
b.writeDoubleLE(11.11, 0, true);
b.writeDoubleBE(11.11, 0, true);