mirror of
https://github.com/0x5eal/rbxts-pako.git
synced 2025-04-04 10:50:59 +01:00
Fixed wrong offset for d_buf
(closes #78)
This commit is contained in:
parent
9790b3cb64
commit
4a07e05823
3 changed files with 26 additions and 1 deletions
|
@ -1364,9 +1364,16 @@ function deflateInit2(strm, level, method, windowBits, memLevel, strategy) {
|
|||
s.lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
|
||||
|
||||
s.pending_buf_size = s.lit_bufsize * 4;
|
||||
|
||||
//overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
|
||||
//s->pending_buf = (uchf *) overlay;
|
||||
s.pending_buf = new utils.Buf8(s.pending_buf_size);
|
||||
|
||||
s.d_buf = s.lit_bufsize >> 1;
|
||||
// It is offset from `s.pending_buf` (size is `s.lit_bufsize * 2`)
|
||||
//s->d_buf = overlay + s->lit_bufsize/sizeof(ush);
|
||||
s.d_buf = 1 * s.lit_bufsize;
|
||||
|
||||
//s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;
|
||||
s.l_buf = (1 + 2) * s.lit_bufsize;
|
||||
|
||||
s.level = level;
|
||||
|
|
|
@ -9,6 +9,10 @@ var zlib = require('zlib');
|
|||
var pako = require('../index');
|
||||
var helpers = require('./helpers');
|
||||
var testSamples = helpers.testSamples;
|
||||
var assert = require('assert');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
|
||||
|
||||
var samples = helpers.loadSamples();
|
||||
|
@ -202,3 +206,17 @@ describe('Deflate dictionary', function () {
|
|||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('Deflate issues', function () {
|
||||
|
||||
it('#78', function () {
|
||||
var data = fs.readFileSync(path.join(__dirname, 'fixtures', 'issue_78.bin'));
|
||||
var options = { level: 6, memLevel: 1 };
|
||||
|
||||
var deflatedPakoData = pako.deflate(data, options);
|
||||
var deflatedZlibData = zlib.deflateSync(data, options);
|
||||
|
||||
assert.equal(deflatedPakoData.length, deflatedZlibData.length);
|
||||
});
|
||||
});
|
||||
|
|
BIN
test/fixtures/issue_78.bin
vendored
Executable file
BIN
test/fixtures/issue_78.bin
vendored
Executable file
Binary file not shown.
Loading…
Add table
Reference in a new issue