File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -7,12 +7,22 @@ common.skipIf32Bits();
77const assert = require ( 'node:assert' ) ;
88const size = 2 ** 31 ;
99
10+ let largeBuffer ;
11+
1012// Test Buffer.alloc with size larger than integer range
1113try {
12- assert . throws ( ( ) => Buffer . alloc ( size ) . toString ( 'utf8' ) , { code : 'ERR_STRING_TOO_LONG' } ) ;
14+ largeBuffer = Buffer . alloc ( size ) ;
1315} catch ( e ) {
14- if ( e . code !== 'ERR_MEMORY_ALLOCATION_FAILED' ) {
15- throw e ;
16+ if (
17+ e . code === 'ERR_MEMORY_ALLOCATION_FAILED' ||
18+ / A r r a y b u f f e r a l l o c a t i o n f a i l e d / . test ( e . message )
19+ ) {
20+ common . skip ( 'insufficient space for Buffer.alloc' ) ;
1621 }
17- common . skip ( 'insufficient space for Buffer.alloc' ) ;
22+
23+ throw e ;
1824}
25+
26+ assert . throws ( ( ) => largeBuffer . toString ( 'utf8' ) , {
27+ code : 'ERR_STRING_TOO_LONG' ,
28+ } ) ;
You can’t perform that action at this time.
0 commit comments