| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -592,7 +592,8 @@ function getStatFsFromBinding(stats) { | |||
| 592 | 592 | function stringToFlags(flags, name = 'flags') { | |
| 593 | 593 | if (typeof flags === 'number') { | |
| 594 | 594 | validateInt32(flags, name); | |
| 595 | - return flags; | ||
| 595 | + // Coerce -0 to +0. | ||
| 596 | + return flags + 0; | ||
| 596 | 597 | } | |
| 597 | 598 | ||
| 598 | 599 | if (flags == null) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -176,6 +176,8 @@ StatWatcher.prototype[kFSStatWatcherStart] = function(filename, | |||
| 176 | 176 | ||
| 177 | 177 | filename = getValidatedPath(filename, 'filename'); | |
| 178 | 178 | validateUint32(interval, 'interval'); | |
| 179 | + // Coerce -0 to +0. | ||
| 180 | + interval += 0; | ||
| 179 | 181 | const err = this._handle.start(toNamespacedPath(filename), interval); | |
| 180 | 182 | if (err) { | |
| 181 | 183 | const error = new UVException({ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -80,7 +80,8 @@ function parseFileMode(value, name, def) { | |||
| 80 | 80 | } | |
| 81 | 81 | ||
| 82 | 82 | validateUint32(value, name); | |
| 83 | - return value; | ||
| 83 | + // Coerce -0 to +0. | ||
| 84 | + return value + 0; | ||
| 84 | 85 | } | |
| 85 | 86 | ||
| 86 | 87 | /** | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,33 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + require('../common'); | ||
| 4 | + | ||
| 5 | + const fs = require('fs'); | ||
| 6 | + const path = require('path'); | ||
| 7 | + const os = require('os'); | ||
| 8 | + | ||
| 9 | + const missing = path.join( | ||
| 10 | + os.tmpdir(), | ||
| 11 | + `node-fs-negative-zero-${process.pid}`, | ||
| 12 | + 'entry', | ||
| 13 | + ); | ||
| 14 | + | ||
| 15 | + function ignoreExpectedError(fn) { | ||
| 16 | + try { | ||
| 17 | + fn(); | ||
| 18 | + } catch { | ||
| 19 | + // Ignore expected file system errors from the missing path. | ||
| 20 | + } | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + const fd = fs.openSync(process.execPath, -0); | ||
| 24 | + fs.closeSync(fd); | ||
| 25 | + | ||
| 26 | + ignoreExpectedError(() => fs.openSync(process.execPath, 'r', -0)); | ||
| 27 | + ignoreExpectedError(() => fs.readFileSync(process.execPath, { flag: -0 })); | ||
| 28 | + ignoreExpectedError(() => fs.mkdirSync(missing, { mode: -0 })); | ||
| 29 | + ignoreExpectedError(() => fs.chmodSync(missing, -0)); | ||
| 30 | + ignoreExpectedError(() => fs.writeFileSync(missing, '', { mode: -0 })); | ||
| 31 | + | ||
| 32 | + fs.watchFile(missing, { interval: -0 }, () => {}); | ||
| 33 | + fs.unwatchFile(missing); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments