fs: mkdtemp shouldn't crash if no callback passed
As it is, `fs.mkdtemp` crashes with a C++ assertion if the callback function is not passed. This patch uses `maybeCallback` to create one, if no callback function is passed. PR-URL: https://github.com/nodejs/node/pull/6828 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
2ef83590ce
commit
dcbf246b35
@ -2000,7 +2000,8 @@ SyncWriteStream.prototype.destroy = function() {
|
||||
|
||||
SyncWriteStream.prototype.destroySoon = SyncWriteStream.prototype.destroy;
|
||||
|
||||
fs.mkdtemp = function(prefix, options, callback) {
|
||||
fs.mkdtemp = function(prefix, options, callback_) {
|
||||
var callback = maybeCallback(callback_);
|
||||
if (!prefix || typeof prefix !== 'string')
|
||||
throw new TypeError('filename prefix is required');
|
||||
|
||||
|
@ -25,3 +25,5 @@ fs.mkdtemp(
|
||||
assert(common.fileExists(folder));
|
||||
})
|
||||
);
|
||||
|
||||
assert.doesNotThrow(() => fs.mkdtemp(path.join(common.tmpDir, 'bar-')));
|
||||
|
Loading…
x
Reference in New Issue
Block a user