In file wabt/src/leb128.cc, function ReadU64Leb128:
This snippet is incorrect. It appears to have been copied from ReadU32Leb128:
else if (p + 9 < end && (p[9] & 0x80) == 0) {
// The top bits set represent values > 32 bits.
if (p[9] & 0xf0) {
return 0;
}
*out_value = LEB128_10(uint64_t);
return 10;
}
The right code is:
else if (p + 9 < end && (p[9] & 0x80) == 0) {
// The top bits set represent values > 64 bits.
if (p[9] & 0xfe) {
return 0;
}
*out_value = LEB128_10(uint64_t);
return 10;
}
The number of used bits in byte 10 equals 64 - 9*7 = 1 bit. Only one bit in the final byte is a part of the 64-bit value. Therefore, all the remaining 7 bits of the last byte must be zero. The check for that is if (p[9] & 0xfe) {.
In file
wabt/src/leb128.cc, functionReadU64Leb128:This snippet is incorrect. It appears to have been copied from
ReadU32Leb128:The right code is:
The number of used bits in byte 10 equals 64 - 9*7 = 1 bit. Only one bit in the final byte is a part of the 64-bit value. Therefore, all the remaining 7 bits of the last byte must be zero. The check for that is
if (p[9] & 0xfe) {.