mirror of
https://github.com/BinomialLLC/basis_universal.git
synced 2026-08-23 19:48:09 +00:00
Adding SAN option to CMakeLists.txt, to make it easier to use clang's address/undefined behavior sanitizer on codebase
Fixing overflow issue on extreme colors in color_distance(). Explicitly disabling unaligned addressing in miniz and transcoder when UBSAN is enabled Disabling a needless optimization in transcoder causing ubsan issues (that could have easily been worked around in a different way, but it was an unnecessary optimization to begin with) Rebuild wasm builds
This commit is contained in:
@@ -37,6 +37,14 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Using unaligned loads and stores causes errors when using UBSan. Jam it off.
|
||||
#if defined(__has_feature)
|
||||
#if __has_feature(undefined_behavior_sanitizer)
|
||||
#undef BASISD_USE_UNALIGNED_WORD_READS
|
||||
#define BASISD_USE_UNALIGNED_WORD_READS 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define BASISD_SUPPORTED_BASIS_VERSION (0x13)
|
||||
|
||||
#ifndef BASISD_SUPPORT_KTX2
|
||||
@@ -12440,12 +12448,8 @@ namespace basist
|
||||
bits = read_bits64(blk.m_bytes, bit_ofs, basisu::minimum<int>(64, 128 - (int)bit_ofs));
|
||||
else
|
||||
{
|
||||
#ifdef __EMSCRIPTEN__
|
||||
bits = blk.m_dwords[2];
|
||||
bits |= (((uint64_t)blk.m_dwords[3]) << 32U);
|
||||
#else
|
||||
bits = blk.m_qwords[1];
|
||||
#endif
|
||||
|
||||
if (bit_ofs >= 64U)
|
||||
bits >>= (bit_ofs - 64U);
|
||||
|
||||
Reference in New Issue
Block a user