Skip to content

Commit

Permalink
Fix undefined behavior in thread.c
Browse files Browse the repository at this point in the history
This was doing pointer addition where i could be >= LUV_THREAD_MAXNUM_ARG and then subtracting afterwards. By doing the subtraction first, the number is properly bounded within 0..LUV_THREAD_MAXNUM_ARG
  • Loading branch information
squeek502 committed Mar 2, 2024
1 parent d6628b4 commit a290979
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static int luv_thread_arg_set(lua_State* L, luv_thread_arg_t* args, int idx, int
args->flags = flags;
while (i <= top && i < LUV_THREAD_MAXNUM_ARG + idx)
{
luv_val_t *arg = args->argv + i - idx;
luv_val_t *arg = args->argv + (i - idx);
arg->type = lua_type(L, i);
arg->ref[0] = arg->ref[1] = LUA_NOREF;
switch (arg->type)
Expand Down

0 comments on commit a290979

Please sign in to comment.