| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5b26439 commit ee66a38
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1604,9 +1604,15 @@ function markNodeModules(ctx, line) { | |||
| 1604 | 1604 | tempLine += StringPrototypeSlice(line, lastPos, moduleStart); | |
| 1605 | 1605 | ||
| 1606 | 1606 | let moduleEnd = StringPrototypeIndexOf(line, separator, moduleStart); | |
| 1607 | - if (line[moduleStart] === '@') { | ||
| 1607 | + if (moduleEnd === -1) { | ||
| 1608 | + // No trailing separator: the module name runs to the end of the line. | ||
| 1609 | + moduleEnd = line.length; | ||
| 1610 | + } else if (line[moduleStart] === '@') { | ||
| 1608 | 1611 | // Namespaced modules have an extra slash: @namespace/package | |
| 1609 | 1612 | moduleEnd = StringPrototypeIndexOf(line, separator, moduleEnd + 1); | |
| 1613 | + if (moduleEnd === -1) { | ||
| 1614 | + moduleEnd = line.length; | ||
| 1615 | + } | ||
| 1610 | 1616 | } | |
| 1611 | 1617 | ||
| 1612 | 1618 | const nodeModule = StringPrototypeSlice(line, moduleStart, moduleEnd); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3418,6 +3418,21 @@ assert.strictEqual( | |||
| 3418 | 3418 | ); | |
| 3419 | 3419 | } | |
| 3420 | 3420 | ||
| 3421 | + { | ||
| 3422 | + // A node_modules segment that is the last path component (no trailing | ||
| 3423 | + // separator after the module name) must not send markNodeModules into an | ||
| 3424 | + // infinite loop that exhausts the heap. | ||
| 3425 | + // https://github.com/nodejs/node/issues/64011 | ||
| 3426 | + const err = new Error('boom'); | ||
| 3427 | + err.stack = 'Error: boom\n at /app/node_modules/foo.js:1:1'; | ||
| 3428 | + const out = util.inspect(err, { colors: true }); | ||
| 3429 | + assert.strictEqual( | ||
| 3430 | + out, | ||
| 3431 | + 'Error: boom\n' + | ||
| 3432 | + ' at /app/node_modules/\x1B[4mfoo.js:1:1\x1B[24m', | ||
| 3433 | + ); | ||
| 3434 | + } | ||
| 3435 | + | ||
| 3421 | 3436 | { | |
| 3422 | 3437 | // Cross platform checks. | |
| 3423 | 3438 | const err = new Error('foo'); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments