Constrain value range of lj_ir_kptr() to unsigned 32 bit pointers.

Thanks to Peter Cawley.
This commit is contained in:
Mike Pall
2016-04-24 17:32:12 +02:00
parent d8ac6230ed
commit ac42037db0
4 changed files with 9 additions and 16 deletions

View File

@@ -843,12 +843,16 @@ static LJ_AINLINE void setlightudV(TValue *o, void *p)
#endif
#if LJ_FR2
#define setcont(o, f) ((o)->u64 = (uint64_t)(uintptr_t)(void *)(f))
#define contptr(f) ((void *)(f))
#define setcont(o, f) ((o)->u64 = (uint64_t)(uintptr_t)contptr(f))
#elif LJ_64
#define contptr(f) \
((void *)(uintptr_t)(uint32_t)((intptr_t)(f) - (intptr_t)lj_vm_asm_begin))
#define setcont(o, f) \
((o)->u64 = (uint64_t)(void *)(f) - (uint64_t)lj_vm_asm_begin)
#else
#define setcont(o, f) setlightudV((o), (void *)(f))
#define contptr(f) ((void *)(f))
#define setcont(o, f) setlightudV((o), contptr(f))
#endif
#define tvchecklive(L, o) \