summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-09-06 09:46:37 -0700
committerAlon Zakai <alonzakai@gmail.com>2016-09-07 12:04:01 -0700
commit5d3fbce683a80a2dcbe17d9e100d6a0a287412ff (patch)
treefbef821ee5e6ec2e632dd1a975417342a6e58c9a
parent135a20cd110d356d5d098a08a7b447205adaed7a (diff)
downloadbinaryen-5d3fbce683a80a2dcbe17d9e100d6a0a287412ff.tar.gz
binaryen-5d3fbce683a80a2dcbe17d9e100d6a0a287412ff.tar.bz2
binaryen-5d3fbce683a80a2dcbe17d9e100d6a0a287412ff.zip
make sure to use the right order of operations when loading composite ints in binary format reading
-rw-r--r--src/wasm-binary.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/wasm-binary.h b/src/wasm-binary.h
index 40671b082..561a310b0 100644
--- a/src/wasm-binary.h
+++ b/src/wasm-binary.h
@@ -1328,19 +1328,22 @@ public:
}
uint16_t getInt16() {
if (debug) std::cerr << "<==" << std::endl;
- auto ret = uint16_t(getInt8()) | (uint16_t(getInt8()) << 8);
+ auto ret = uint16_t(getInt8());
+ ret |= uint16_t(getInt8()) << 8;
if (debug) std::cerr << "getInt16: " << ret << " ==>" << std::endl;
return ret;
}
uint32_t getInt32() {
if (debug) std::cerr << "<==" << std::endl;
- auto ret = uint32_t(getInt16()) | (uint32_t(getInt16()) << 16);
+ auto ret = uint32_t(getInt16());
+ ret |= uint32_t(getInt16()) << 16;
if (debug) std::cerr << "getInt32: " << ret << " ==>" << std::endl;
return ret;
}
uint64_t getInt64() {
if (debug) std::cerr << "<==" << std::endl;
- auto ret = uint64_t(getInt32()) | (uint64_t(getInt32()) << 32);
+ auto ret = uint64_t(getInt32());
+ ret |= uint64_t(getInt32()) << 32;
if (debug) std::cerr << "getInt64: " << ret << " ==>" << std::endl;
return ret;
}