diff options
author | James Zern <jzern@google.com> | 2023-07-06 15:53:26 -0700 |
---|---|---|
committer | James Zern <jzern@google.com> | 2023-07-07 09:17:45 -0700 |
commit | 21f329f09baf689d48c608d51b4e0e7eedbed998 (patch) | |
tree | 13b094959e70472c038df1814718b1ce757113e6 | |
parent | 3d554568ced97f0b7adeb132188190a83b061754 (diff) | |
download | libwebm-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.cc | 6 |
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; |