Closed
Description
- Version: 4.5.0 and 6.5.0
- Platform: OSX and Linux (didn't test windows)
- Subsystem: zlib
The following script fails:
const zlib = require('zlib');
const serialized = new Buffer('mytexttocompresshere');
const zlibDictionary = new Buffer('texttocompress');
const zlibOptions = {dictionary: zlibDictionary};
const deflated = zlib.deflateRawSync(serialized, zlibOptions);
const inflated = zlib.inflateRawSync(deflated, zlibOptions);
console.log(inflated.equals(serialized));
With the following traceback (the crash comes from the inflateRawSync
line):
zlib.js:535
throw error;
^
Error: invalid distance too far back
at Zlib._handle.onerror (zlib.js:363:17)
at InflateRaw.Zlib._processChunk (zlib.js:525:30)
at zlibBufferSync (zlib.js:239:17)
at Object.exports.inflateRawSync (zlib.js:187:10)
at Object.<anonymous> (~/testRawDeflate.js:8:23)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Function.Module.runMain (module.js:467:10)
If the dictionary argument is removed it works, and similarly the non-raw alternatives work (outputs true
as expected). Not sure if relevant, but all test cases was against zlib 1.2.8 (console.log(process.binding('zlib').ZLIB_VERSION);
).
The same problem exists for the async functions too.