mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 928738 - Safely pun double and float. r=jandem
This commit is contained in:
parent
27e178e063
commit
91aa788491
@ -1249,6 +1249,11 @@ SnapshotIterator::slotReadable(const Slot &slot)
|
||||
}
|
||||
}
|
||||
|
||||
typedef union {
|
||||
double d;
|
||||
float f;
|
||||
} PunDoubleFloat;
|
||||
|
||||
Value
|
||||
SnapshotIterator::slotValue(const Slot &slot)
|
||||
{
|
||||
@ -1258,17 +1263,19 @@ SnapshotIterator::slotValue(const Slot &slot)
|
||||
|
||||
case SnapshotReader::FLOAT32_REG:
|
||||
{
|
||||
double asDouble = machine_.read(slot.floatReg());
|
||||
PunDoubleFloat pdf;
|
||||
pdf.d = machine_.read(slot.floatReg());
|
||||
// The register contains the encoding of a float32. We just read
|
||||
// the bits without making any conversion.
|
||||
float asFloat = *(float*) &asDouble;
|
||||
float asFloat = pdf.f;
|
||||
return DoubleValue(asFloat);
|
||||
}
|
||||
|
||||
case SnapshotReader::FLOAT32_STACK:
|
||||
{
|
||||
double asDouble = ReadFrameDoubleSlot(fp_, slot.stackSlot());
|
||||
float asFloat = *(float*) &asDouble; // no conversion, see comment above.
|
||||
PunDoubleFloat pdf;
|
||||
pdf.d = ReadFrameDoubleSlot(fp_, slot.stackSlot());
|
||||
float asFloat = pdf.f; // no conversion, see comment above.
|
||||
return DoubleValue(asFloat);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user