diff options
author | Sakthipriyan Vairamani <thechargingvolcano@gmail.com> | 2016-05-30 23:15:01 +0530 |
---|---|---|
committer | Sakthipriyan Vairamani <thechargingvolcano@gmail.com> | 2016-06-04 16:31:18 +0530 |
commit | c4fadbc15de5f7dbbe607e29bf90cbbd8b5fa6f5 (patch) | |
tree | 3b7c87a01022685a6f8e967ee22fce5e819f99a6 /lib | |
parent | 1a21524b6908892e2d0a79cbb4241aee78530c09 (diff) | |
download | android-node-v8-c4fadbc15de5f7dbbe607e29bf90cbbd8b5fa6f5.tar.gz android-node-v8-c4fadbc15de5f7dbbe607e29bf90cbbd8b5fa6f5.tar.bz2 android-node-v8-c4fadbc15de5f7dbbe607e29bf90cbbd8b5fa6f5.zip |
fs: execute mkdtemp's callback with no context
All the callback functions in `fs` module are supposed to be executed
with no context (`this` value should not be a valid object). But
`mkdtemp`'s callback will have the `FSReqWrap` object as the context.
Sample code to reproduce the problem
'use strict';
const fs = require('fs');
fs.mkdtemp('/tmp/abcd', null, function() {
console.log(this);
});
This would print
FSReqWrap { oncomplete: [Function] }
But that should have printed `null` and this patch fixes that.
PR-URL: https://github.com/nodejs/node/pull/7068
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fs.js | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -1596,8 +1596,7 @@ fs.realpath = function realpath(path, options, callback) { }; -fs.mkdtemp = function(prefix, options, callback_) { - var callback = maybeCallback(callback_); +fs.mkdtemp = function(prefix, options, callback) { if (!prefix || typeof prefix !== 'string') throw new TypeError('filename prefix is required'); @@ -1611,6 +1610,7 @@ fs.mkdtemp = function(prefix, options, callback_) { if (typeof options !== 'object') throw new TypeError('"options" must be a string or an object'); + callback = makeCallback(callback); if (!nullCheck(prefix, callback)) { return; } |