@@ -503,7 +503,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
code[i] = vec;
code[i] = vec;
vec++;
vec++;
}
}
};
}
vec <<= 1;
vec <<= 1;
}
}
}
}
@@ -703,7 +703,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
bc = cost[t];
bc = cost[t];
bt = t;
bt = t;
}
}
};
}
totc += bc;
totc += bc;
fave[bt]++;
fave[bt]++;
selector[nSelectors] = (char) bt;
selector[nSelectors] = (char) bt;
@@ -1047,7 +1047,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
ltLo++;
ltLo++;
unLo++;
unLo++;
continue;
continue;
};
}
if (n > 0) {
if (n > 0) {
break;
break;
}
}
@@ -1066,7 +1066,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
gtHi--;
gtHi--;
unHi--;
unHi--;
continue;
continue;
};
}
if (n < 0) {
if (n < 0) {
break;
break;
}
}
@@ -1131,6 +1131,15 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
*/
*/
// if (verbosity >= 4) fprintf ( stderr, " sort initialise ...\n" );
// if (verbosity >= 4) fprintf ( stderr, " sort initialise ...\n" );
// set last to zero in case it's never been set before
// see bug#32200, initBlock is the real culprit
// setting last to -1, but not sure if this -1 is important
// in normal scheme
if (last < 0) {
last = 0;
}
for (i = 0; i < NUM_OVERSHOOT_BYTES; i++) {
for (i = 0; i < NUM_OVERSHOOT_BYTES; i++) {
block[last + i + 2] = block[(i % (last + 1)) + 1];
block[last + i + 2] = block[(i % (last + 1)) + 1];
}
}
@@ -1360,7 +1369,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
origPtr = i;
origPtr = i;
break;
break;
}
}
};
}
if (origPtr == -1) {
if (origPtr == -1) {
panic();
panic();
@@ -1478,11 +1487,11 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
if (i1 > last) {
if (i1 > last) {
i1 -= last;
i1 -= last;
i1--;
i1--;
};
}
if (i2 > last) {
if (i2 > last) {
i2 -= last;
i2 -= last;
i2--;
i2--;
};
}
k -= 4;
k -= 4;
workDone++;
workDone++;
@@ -1565,7 +1574,7 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
tmp2 = tmp;
tmp2 = tmp;
tmp = yy[j];
tmp = yy[j];
yy[j] = tmp2;
yy[j] = tmp2;
};
}
yy[0] = tmp;
yy[0] = tmp;
if (j == 0) {
if (j == 0) {
@@ -1585,12 +1594,12 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
wr++;
wr++;
mtfFreq[RUNB]++;
mtfFreq[RUNB]++;
break;
break;
};
}
if (zPend < 2) {
if (zPend < 2) {
break;
break;
}
}
zPend = (zPend - 2) / 2;
zPend = (zPend - 2) / 2;
};
}
zPend = 0;
zPend = 0;
}
}
szptr[wr] = (short) (j + 1);
szptr[wr] = (short) (j + 1);
@@ -1627,6 +1636,4 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants {
nMTF = wr;
nMTF = wr;
}
}
}
}