Skip to content

Commit 62b2236

Browse files
committed
tests/capi: fix UB in a torture_test
1 parent 802fbe7 commit 62b2236

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tests/capi/torture_test.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,7 +1717,8 @@ static lua_func push_func[] = {
17171717
static void
17181718
lua_pushrandom(lua_State *L, FuzzedDataProvider *fdp)
17191719
{
1720-
uint8_t idx = fdp->ConsumeIntegralInRange(0, (int)ARRAY_SIZE(push_func) - 1);
1720+
uint8_t idx = fdp->ConsumeIntegralInRange<uint8_t>(0, ARRAY_SIZE(push_func) - 1);
1721+
17211722
push_func[idx](L, fdp);
17221723

17231724
bool is_set_mt = fdp->ConsumeBool();
@@ -1903,7 +1904,7 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
19031904
fdp.remaining_bytes() != 0) {
19041905
__lua_gc(L, &fdp);
19051906
__lua_sethook(L, &fdp);
1906-
uint8_t idx = fdp.ConsumeIntegralInRange<uint8_t>(0, (int)ARRAY_SIZE(func) - 1);
1907+
uint8_t idx = fdp.ConsumeIntegralInRange<uint8_t>(0, ARRAY_SIZE(func) - 1);
19071908
func[idx](L, &fdp);
19081909
}
19091910

0 commit comments

Comments
 (0)