diff --git a/package.json b/package.json index 6c87254..2d62f54 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fflate", - "version": "0.6.6", + "version": "0.6.7", "description": "High performance (de)compression in an 8kB package", "main": "./lib/index.cjs", "module": "./esm/browser.js", diff --git a/src/index.ts b/src/index.ts index e02d762..443a3c3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3039,6 +3039,7 @@ export class Unzip { else if (dd) sc = -1; i += es; this.c = sc; + let d: UnzipDecoder; const file = { name: fn, compression: cmp, @@ -3048,15 +3049,15 @@ export class Unzip { else { const ctr = this.o[cmp]; if (!ctr) throw 'unknown compression type ' + cmp; - const d = sc < 0 ? new ctr(fn) : new ctr(fn, sc, su); + d = sc < 0 ? new ctr(fn) : new ctr(fn, sc, su); d.ondata = (err, dat, final) => { file.ondata(err, dat, final); } for (const dat of chks) d.push(dat, false); - if (this.k[0] == chks) this.d = d; + if (this.k[0] == chks && this.c) this.d = d; else d.push(et, true); } }, terminate: () => { - if (this.k[0] == chks && this.d.terminate) this.d.terminate(); + if (d && d.terminate) d.terminate(); } } as UnzipFile; if (sc >= 0) file.size = sc, file.originalSize = su;