summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Zern <jzern@google.com>2023-07-06 15:53:26 -0700
committerJames Zern <jzern@google.com>2023-07-07 09:17:45 -0700
commit21f329f09baf689d48c608d51b4e0e7eedbed998 (patch)
tree13b094959e70472c038df1814718b1ce757113e6
parent3d554568ced97f0b7adeb132188190a83b061754 (diff)
downloadlibwebm-21f329f09baf689d48c608d51b4e0e7eedbed998.tar.gz
fix UnserializeFloat w/big endian
Use fixed size type for the integer component of the float union; unsigned long may be 8 bytes, so would only work on little endian machines when aliasing it as a 4 byte float. The double union is updated to match. Bug: webm:1806 Change-Id: Ib0898d2d63abc03974a1f078815b7f916eafcb4b
-rw-r--r--mkvparser/mkvparser.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/mkvparser/mkvparser.cc b/mkvparser/mkvparser.cc
index de0fafc..bd52af1 100644
--- a/mkvparser/mkvparser.cc
+++ b/mkvparser/mkvparser.cc
@@ -246,7 +246,8 @@ long UnserializeFloat(IMkvReader* pReader, long long pos, long long size_,
if (size == 4) {
union {
float f;
- unsigned long ff;
+ uint32_t ff;
+ static_assert(sizeof(float) == sizeof(uint32_t), "");
};
ff = 0;
@@ -264,7 +265,8 @@ long UnserializeFloat(IMkvReader* pReader, long long pos, long long size_,
} else {
union {
double d;
- unsigned long long dd;
+ uint64_t dd;
+ static_assert(sizeof(double) == sizeof(uint64_t), "");
};
dd = 0;