mirror of
https://github.com/billsonnn/nitro-converter.git
synced 2024-11-22 23:50:52 +01:00
Merge branch 'BiFi2000-master-patch-27063' into 'master'
optimize zlib inflate, the old code would get stuck on malformed swfs See merge request nitro/nitro-converter!4
This commit is contained in:
commit
450d306cc8
@ -335,27 +335,9 @@ function uncompress(swf, next) {
|
||||
return readSWFBuff(new SWFBuffer(uncompressed_buff), swf);
|
||||
}
|
||||
|
||||
const newBuffer = swf.slice(4);
|
||||
const uncompressedLength = newBuffer.readUInt32LE();
|
||||
const chunks = [];
|
||||
|
||||
let readLength = 0;
|
||||
var decompressStream = zlib.createInflate()
|
||||
.on('data', function (chunk) {
|
||||
readLength += chunk.length;
|
||||
chunks.push(chunk);
|
||||
|
||||
if (uncompressedLength - 8 === readLength) {
|
||||
decompressStream.close();
|
||||
}
|
||||
//decompressStream.pause();
|
||||
}).on('error', function(err) {
|
||||
console.log(err);
|
||||
//next(err);
|
||||
}).on('close', function() {
|
||||
readSWFBuff(new SWFBuffer( Buffer.concat(chunks) ), swf, next);
|
||||
zlib.inflate(compressed_buff, function(err, buf) {
|
||||
readSWFBuff(new SWFBuffer(buf), swf, next);
|
||||
});
|
||||
decompressStream.write(compressed_buff);
|
||||
break;
|
||||
case 0x46 : // uncompressed
|
||||
return readSWFBuff(new SWFBuffer( swf ), swf, next);
|
||||
|
Loading…
Reference in New Issue
Block a user