File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Expand file tree Collapse file tree 1 file changed +15
-5
lines 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
+
12
+ // Test Buffer.allocUnsafe with size larger than integer range
10
13
try {
11
- // Test Buffer.allocUnsafe with size larger than integer range
12
- assert . throws ( ( ) => Buffer . allocUnsafe ( size ) . toString ( 'utf8' ) , { code : 'ERR_STRING_TOO_LONG' } ) ;
14
+ largeBuffer = Buffer . allocUnsafe ( 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
+ / 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.allocUnsafe' ) ;
16
21
}
17
- common . skip ( 'insufficient space for Buffer.allocUnsafe' ) ;
22
+
23
+ throw e ;
18
24
}
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