Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
util: ensure that the .inspect function isn't the one being executed
Browse files Browse the repository at this point in the history
Fixes #2225.
  • Loading branch information
TooTallNate authored and bnoordhuis committed Nov 30, 2011
1 parent 754e23d commit b204006
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/util.js
Expand Up @@ -155,7 +155,7 @@ function formatValue(ctx, value, recurseTimes) {
// Check that value is an object with an inspect function on it
if (value && typeof value.inspect === 'function' &&
// Filter out the util module, it's inspect function is special
value !== exports &&
value.inspect !== exports.inspect &&
// Also filter out any prototype objects using the circular check.
!(value.constructor && value.constructor.prototype === value)) {
return value.inspect(recurseTimes);
Expand Down
4 changes: 4 additions & 0 deletions test/simple/test-util-inspect.js
Expand Up @@ -75,3 +75,7 @@ assert.doesNotThrow(function () {
r.toString = null;
util.inspect(r);
});

// GH-2225
var x = { inspect: util.inspect };
assert.ok(util.inspect(x).indexOf('inspect') != -1);

0 comments on commit b204006

Please sign in to comment.