diff options
author | Mike Pall <mike> | 2022-12-22 00:03:06 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2022-12-22 00:03:06 +0100 |
commit | 8a5e398c52c7f8ca3e1a0e574cc2ba38224b759b (patch) | |
tree | dae089564f58db2963bae8e3530c1faae104cc61 /src/lj_obj.h | |
parent | b2791179ef96d652d00d78d2a8780af690537f6a (diff) | |
download | luajit-8a5e398c52c7f8ca3e1a0e574cc2ba38224b759b.tar.gz luajit-8a5e398c52c7f8ca3e1a0e574cc2ba38224b759b.tar.bz2 luajit-8a5e398c52c7f8ca3e1a0e574cc2ba38224b759b.zip |
Avoid negation of signed integers in C that may hold INT*_MIN.
Reported by minoki.
Recent C compilers 'take advantage' of the undefined behavior.
This completely changes the meaning of expressions like (k == -k).
Diffstat (limited to 'src/lj_obj.h')
-rw-r--r-- | src/lj_obj.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/lj_obj.h b/src/lj_obj.h index ea8fe870..ef45ae12 100644 --- a/src/lj_obj.h +++ b/src/lj_obj.h | |||
@@ -327,7 +327,7 @@ typedef struct GCproto { | |||
327 | #define PROTO_UV_IMMUTABLE 0x4000 /* Immutable upvalue. */ | 327 | #define PROTO_UV_IMMUTABLE 0x4000 /* Immutable upvalue. */ |
328 | 328 | ||
329 | #define proto_kgc(pt, idx) \ | 329 | #define proto_kgc(pt, idx) \ |
330 | check_exp((uintptr_t)(intptr_t)(idx) >= (uintptr_t)-(intptr_t)(pt)->sizekgc, \ | 330 | check_exp((uintptr_t)(intptr_t)(idx) >= ~(uintptr_t)(pt)->sizekgc+1u, \ |
331 | gcref(mref((pt)->k, GCRef)[(idx)])) | 331 | gcref(mref((pt)->k, GCRef)[(idx)])) |
332 | #define proto_knumtv(pt, idx) \ | 332 | #define proto_knumtv(pt, idx) \ |
333 | check_exp((uintptr_t)(idx) < (pt)->sizekn, &mref((pt)->k, TValue)[(idx)]) | 333 | check_exp((uintptr_t)(idx) < (pt)->sizekn, &mref((pt)->k, TValue)[(idx)]) |