| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0605555 commit e966d1f
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -148,8 +148,6 @@ Buffer.alloc = function(size, fill, encoding) { | |||
| 148 | 148 | Buffer.allocUnsafe = function(size) { | |
| 149 | 149 | if (typeof size !== 'number') | |
| 150 | 150 | throw new TypeError('"size" argument must be a number'); | |
| 151 | - if (size > 0) | ||
| 152 | - flags[kNoZeroFill] = 1; | ||
| 153 | 151 | return allocate(size); | |
| 154 | 152 | }; | |
| 155 | 153 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,8 +7,18 @@ const safe = Buffer.alloc(10); | |||
| 7 | 7 | ||
| 8 | 8 | function isZeroFilled(buf) { | |
| 9 | 9 | for (let n = 0; n < buf.length; n++) | |
| 10 | - if (buf[n] > 0) return false; | ||
| 10 | + if (buf[n] !== 0) return false; | ||
| 11 | 11 | return true; | |
| 12 | 12 | } | |
| 13 | 13 | ||
| 14 | 14 | assert(isZeroFilled(safe)); | |
| 15 | + | ||
| 16 | + // Test that unsafe allocations doesn't affect subsequent safe allocations | ||
| 17 | + Buffer.allocUnsafe(10); | ||
| 18 | + assert(isZeroFilled(new Float64Array(10))); | ||
| 19 | + | ||
| 20 | + new Buffer(10); | ||
| 21 | + assert(isZeroFilled(new Float64Array(10))); | ||
| 22 | + | ||
| 23 | + Buffer.allocUnsafe(10); | ||
| 24 | + assert(isZeroFilled(Buffer.alloc(10))); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments