Fix a crash with tabledivide64()

Fixes #1.
This commit is contained in:
Richard C. Gobeille 2020-04-20 12:51:36 -07:00 committed by Christoph Oelckers
parent 79d2bb1bb8
commit 94d098f8ef

View file

@ -52,8 +52,8 @@ skip:
static inline int64_t tabledivide64(int64_t const n, int64_t const d)
{
static libdivide::libdivide_s64_t sdiv;
static int32_t lastd;
auto const dptr = ((unsigned)d < DIVTABLESIZE) ? &divtable64[d] : &sdiv;
static int64_t lastd;
auto const dptr = ((uint64_t)d < DIVTABLESIZE) ? &divtable64[d] : &sdiv;
if (d == lastd || dptr != &sdiv)
goto skip;
@ -67,7 +67,7 @@ static inline int32_t tabledivide32(int32_t const n, int32_t const d)
{
static libdivide::libdivide_s32_t sdiv;
static int32_t lastd;
auto const dptr = ((unsigned)d < DIVTABLESIZE) ? &divtable32[d] : &sdiv;
auto const dptr = ((uint32_t)d < DIVTABLESIZE) ? &divtable32[d] : &sdiv;
if (d == lastd || dptr != &sdiv)
goto skip;