mirror of https://github.com/nodejs/node.git
smalloc: check if obj has external data
PR-URL: https://github.com/joyent/node/pull/8655 Reviewed-by: Trevor Norris <trev.norris@gmail.com>pull/1/head
parent
849fcdeca0
commit
f65a5cbcde
|
@ -86,6 +86,8 @@ function dispose(obj) {
|
||||||
throw new TypeError('obj must be an Object');
|
throw new TypeError('obj must be an Object');
|
||||||
if (util.isBuffer(obj))
|
if (util.isBuffer(obj))
|
||||||
throw new TypeError('obj cannot be a Buffer');
|
throw new TypeError('obj cannot be a Buffer');
|
||||||
|
if (!smalloc.hasExternalData(obj))
|
||||||
|
throw new Error('obj has no external array data');
|
||||||
|
|
||||||
smalloc.dispose(obj);
|
smalloc.dispose(obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -314,11 +314,15 @@ for (var i = 0; i < 5; i++)
|
||||||
|
|
||||||
// only allow object to be passed to dispose
|
// only allow object to be passed to dispose
|
||||||
assert.throws(function() {
|
assert.throws(function() {
|
||||||
alloc.dispose(null);
|
smalloc.dispose(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// can't dispose a Buffer
|
// can't dispose a Buffer
|
||||||
assert.throws(function() {
|
assert.throws(function() {
|
||||||
alloc.dispose(new Buffer());
|
smalloc.dispose(new Buffer());
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(function() {
|
||||||
|
smalloc.dispose({});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue