mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-11 21:49:13 +00:00
Avoid overflow.
This commit is contained in:
Binary file not shown.
@@ -1325,11 +1325,11 @@
|
||||
)
|
||||
(i32.const 0)
|
||||
(i32.le_u
|
||||
(local.get $0)
|
||||
(i32.add
|
||||
(local.get $1)
|
||||
(i32.sub
|
||||
(local.get $0)
|
||||
(local.get $3)
|
||||
)
|
||||
(local.get $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -113,7 +113,7 @@ void *memchr(const void *v, int c, size_t n) {
|
||||
// That's a match, unless it is beyond the end of the object.
|
||||
// Recall that we decremented n, so less-than-or-equal-to is correct.
|
||||
size_t ctz = __builtin_ctz(mask);
|
||||
return ctz <= n + align ? (char *)w + ctz : NULL;
|
||||
return ctz - align <= n ? (char *)w + ctz : NULL;
|
||||
}
|
||||
}
|
||||
// Decrement n; if it overflows we're done.
|
||||
@@ -166,6 +166,8 @@ size_t strlen(const char *s) {
|
||||
// At least one bit will be set, unless we cleared them.
|
||||
// Knowing this helps the compiler.
|
||||
__builtin_assume(mask || align);
|
||||
// If the mask is zero because of alignment,
|
||||
// it's as if we didn't find anything.
|
||||
if (mask) {
|
||||
// Find the offset of the first one bit (little-endian).
|
||||
return (char *)w - s + __builtin_ctz(mask);
|
||||
@@ -280,6 +282,8 @@ static char *__strchrnul(const char *s, int c) {
|
||||
// At least one bit will be set, unless we cleared them.
|
||||
// Knowing this helps the compiler.
|
||||
__builtin_assume(mask || align);
|
||||
// If the mask is zero because of alignment,
|
||||
// it's as if we didn't find anything.
|
||||
if (mask) {
|
||||
// Find the offset of the first one bit (little-endian).
|
||||
return (char *)w + __builtin_ctz(mask);
|
||||
|
||||
@@ -57,6 +57,7 @@ int bcmp(const void *v1, const void *v2, size_t n) {
|
||||
|
||||
#endif // __OPTIMIZE_SIZE__
|
||||
|
||||
__attribute__((always_inline))
|
||||
static v128_t __tolower8x16(v128_t v) {
|
||||
__i8x16 i = v;
|
||||
i = i + wasm_i8x16_splat(INT8_MAX - ('Z'));
|
||||
|
||||
Reference in New Issue
Block a user