Fix issues reported by gcc -fsanitize flag (#678)

And refine some coding styles, fix JIT compiler data wasm table create issue, add license header for some files.
This commit is contained in:
Wenyong Huang
2021-07-30 15:21:17 +08:00
committed by GitHub
parent 62fb3c9a89
commit 7cdfc9fe11
14 changed files with 84 additions and 108 deletions

View File

@ -89,9 +89,9 @@ read_leb(uint8 **p_buf, const uint8 *buf_end,
}
else if (sign && maxbits == 32) {
if (shift < maxbits) {
/* Sign extend */
result = (((int32)result) << (maxbits - shift))
>> (maxbits - shift);
/* Sign extend, second highest bit is the sign bit */
if ((uint8)byte & 0x40)
result |= (~((uint64)0)) << shift;
}
else {
/* The top bits should be a sign-extension of the sign bit */
@ -105,9 +105,9 @@ read_leb(uint8 **p_buf, const uint8 *buf_end,
}
else if (sign && maxbits == 64) {
if (shift < maxbits) {
/* Sign extend */
result = (((int64)result) << (maxbits - shift))
>> (maxbits - shift);
/* Sign extend, second highest bit is the sign bit */
if ((uint8)byte & 0x40)
result |= (~((uint64)0)) << shift;
}
else {
/* The top bits should be a sign-extension of the sign bit */