Skip to content

Commit 6970045

Browse files
committed
add regression test
1 parent ce770de commit 6970045

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict';
2+
3+
const assert = require('assert');
4+
5+
// Change kMaxLength for zlib to trigger the error
6+
// without having to allocate 1GB of buffers
7+
const smalloc = process.binding('smalloc');
8+
smalloc.kMaxLength = 128;
9+
const zlib = require('zlib');
10+
smalloc.kMaxLength = 0x3fffffff;
11+
12+
const encoded = new Buffer('H4sIAAAAAAAAA0tMHFgAAIw2K/GAAAAA', 'base64');
13+
14+
// Async
15+
zlib.gunzip(encoded, function(err) {
16+
assert.ok(err instanceof RangeError);
17+
});
18+
19+
// Sync
20+
assert.throws(function() {
21+
zlib.gunzipSync(encoded);
22+
}, RangeError);

0 commit comments

Comments
 (0)