Bug 779694 - Handle zlib errors correctly. r=jorendorff

This commit is contained in:
Benjamin Peterson 2012-08-02 13:31:45 -07:00
parent c07fc94e51
commit 8a6a085f31
2 changed files with 11 additions and 1 deletions

View File

@ -0,0 +1,6 @@
var x = "";
for (var i=0; i<400; ++i) {
x += String.fromCharCode(i * 289);
}
var s = "'" + x + "'";
assertEq(Function("evt", s).toString(), "function anonymous(evt) {\n" + s + "\n}");

View File

@ -67,7 +67,11 @@ Compressor::compressMore()
else if (zs.avail_in == 0)
zs.avail_in = CHUNKSIZE;
int ret = deflate(&zs, done ? Z_FINISH : Z_NO_FLUSH);
if (ret == Z_BUF_ERROR) {
if (ret == Z_MEM_ERROR) {
zs.avail_out = 0;
return false;
}
if (ret == Z_BUF_ERROR || (done && ret == Z_OK)) {
JS_ASSERT(zs.avail_out == 0);
return false;
}