mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
3806d875d3
If the accumulation of data for the final Buffer is greater than kMaxLength it will throw an un-catchable RangeError. Instead now pass the generated error to the callback. PR-URL: https://github.com/nodejs/io.js/pull/1811 Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
23 lines
525 B
JavaScript
23 lines
525 B
JavaScript
'use strict';
|
|
|
|
const assert = require('assert');
|
|
|
|
// Change kMaxLength for zlib to trigger the error
|
|
// without having to allocate 1GB of buffers
|
|
const smalloc = process.binding('smalloc');
|
|
smalloc.kMaxLength = 128;
|
|
const zlib = require('zlib');
|
|
smalloc.kMaxLength = 0x3fffffff;
|
|
|
|
const encoded = new Buffer('H4sIAAAAAAAAA0tMHFgAAIw2K/GAAAAA', 'base64');
|
|
|
|
// Async
|
|
zlib.gunzip(encoded, function(err) {
|
|
assert.ok(err instanceof RangeError);
|
|
});
|
|
|
|
// Sync
|
|
assert.throws(function() {
|
|
zlib.gunzipSync(encoded);
|
|
}, RangeError);
|