mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-03 05:25:29 +00:00
Fixed #1949 Incorrect reading FIXED and FIXED8 SWF values causing wrong Filters size and OutOfMemory
This commit is contained in:
@@ -593,14 +593,19 @@ public class SWFInputStream implements AutoCloseable {
|
||||
*/
|
||||
public long readSI32(String name) throws IOException {
|
||||
newDumpLevel(name, "SI32");
|
||||
long uval = readEx() + (readEx() << 8) + (readEx() << 16) + (readEx() << 24);
|
||||
if (uval >= 0x80000000) {
|
||||
uval = -(((~uval) & 0xffffffff) + 1);
|
||||
}
|
||||
long uval = readSI32Internal();
|
||||
endDumpLevel(uval);
|
||||
return uval;
|
||||
}
|
||||
|
||||
private long readSI32Internal() throws IOException {
|
||||
long uval = readEx() + (readEx() << 8) + (readEx() << 16) + (readEx() << 24);
|
||||
if (uval >= 0x80000000) {
|
||||
uval = -(((~uval) & 0xffffffff) + 1);
|
||||
}
|
||||
return uval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads one SI16 (Signed 16bit integer) value from the stream
|
||||
*
|
||||
@@ -610,11 +615,16 @@ public class SWFInputStream implements AutoCloseable {
|
||||
*/
|
||||
public int readSI16(String name) throws IOException {
|
||||
newDumpLevel(name, "SI16");
|
||||
int uval = readSI16Internal();
|
||||
endDumpLevel(uval);
|
||||
return uval;
|
||||
}
|
||||
|
||||
private int readSI16Internal() throws IOException {
|
||||
int uval = readEx() + (readEx() << 8);
|
||||
if (uval >= 0x8000) {
|
||||
uval = -(((~uval) & 0xffff) + 1);
|
||||
}
|
||||
endDumpLevel(uval);
|
||||
return uval;
|
||||
}
|
||||
|
||||
@@ -655,9 +665,8 @@ public class SWFInputStream implements AutoCloseable {
|
||||
*/
|
||||
public double readFIXED(String name) throws IOException {
|
||||
newDumpLevel(name, "FIXED");
|
||||
int afterPoint = readUI16Internal();
|
||||
int beforePoint = readUI16Internal();
|
||||
double ret = beforePoint + ((double) (afterPoint)) / 65536;
|
||||
long si = readSI32Internal();
|
||||
double ret = si / (double)(1 << 16);
|
||||
endDumpLevel(ret);
|
||||
return ret;
|
||||
}
|
||||
@@ -671,9 +680,8 @@ public class SWFInputStream implements AutoCloseable {
|
||||
*/
|
||||
public float readFIXED8(String name) throws IOException {
|
||||
newDumpLevel(name, "FIXED8");
|
||||
int afterPoint = readEx();
|
||||
int beforePoint = readSI8Internal();
|
||||
float ret = beforePoint + ((float) afterPoint) / 256;
|
||||
int si = readSI16Internal();
|
||||
float ret = si / (float)(1 << 8);
|
||||
endDumpLevel(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -285,10 +285,7 @@ public class SWFOutputStream extends OutputStream {
|
||||
*/
|
||||
public void writeFIXED(double value) throws IOException {
|
||||
long valueLong = (long) (value * (1 << 16));
|
||||
int beforePoint = (int) valueLong >> 16;
|
||||
int afterPoint = (int) valueLong % (1 << 16);
|
||||
writeUI16(afterPoint);
|
||||
writeUI16(beforePoint);
|
||||
writeSI32(valueLong);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -299,10 +296,7 @@ public class SWFOutputStream extends OutputStream {
|
||||
*/
|
||||
public void writeFIXED8(float value) throws IOException {
|
||||
int valueInt = (int) (value * (1 << 8));
|
||||
int beforePoint = (int) valueInt >> 8;
|
||||
int afterPoint = (int) valueInt % (1 << 8);
|
||||
writeUI8(afterPoint);
|
||||
writeSI8(beforePoint);
|
||||
writeSI16(valueInt);
|
||||
}
|
||||
|
||||
private void writeLong(long value) throws IOException {
|
||||
|
||||
Reference in New Issue
Block a user