| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7bb1246 commit d94b184
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,12 +7,22 @@ common.skipIf32Bits(); | |||
| 7 | 7 | const assert = require('node:assert'); | |
| 8 | 8 | const size = 2 ** 31; | |
| 9 | 9 | ||
| 10 | + let largeBuffer; | ||
| 11 | + | ||
| 10 | 12 | // Test Buffer.alloc with size larger than integer range | |
| 11 | 13 | try { | |
| 12 | - assert.throws(() => Buffer.alloc(size).toString('utf8'), { code: 'ERR_STRING_TOO_LONG' }); | ||
| 14 | + largeBuffer = Buffer.alloc(size); | ||
| 13 | 15 | } catch (e) { | |
| 14 | - if (e.code !== 'ERR_MEMORY_ALLOCATION_FAILED') { | ||
| 15 | - throw e; | ||
| 16 | + if ( | ||
| 17 | + e.code === 'ERR_MEMORY_ALLOCATION_FAILED' || | ||
| 18 | + /Array buffer allocation failed/.test(e.message) | ||
| 19 | + ) { | ||
| 20 | + common.skip('insufficient space for Buffer.alloc'); | ||
| 16 | 21 | } | |
| 17 | - common.skip('insufficient space for Buffer.alloc'); | ||
| 22 | + | ||
| 23 | + throw e; | ||
| 18 | 24 | } | |
| 25 | + | ||
| 26 | + assert.throws(() => largeBuffer.toString('utf8'), { | ||
| 27 | + code: 'ERR_STRING_TOO_LONG', | ||
| 28 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments