winapi icon indicating copy to clipboard operation
winapi copied to clipboard

call_lua_direct with REF_IDX incorrectly pushes argument to lua_call

Open ma-bo opened this issue 6 years ago • 1 comments

For example, on line winapi.c:2080 lcb_call(parms,-1,0,REF_IDX); // pass it a new File reference

In wutils.c:119 BOOL call_lua_direct(lua_State *L, Ref ref, int idx, const char *text, int flags) { if (flags & REF_IDX) lua_pushvalue(L,idx);

idx == -1, but push_ref(L,ref) pushes the function to the top of the stack, making lua_pushvalue(L,idx) incorrect.

ma-bo avatar Jun 19 '19 19:06 ma-bo

Potential solution to account for the off by one error for negative indicies: lua_pushvalue(L,idx < 0 ? --idx : idx)

ma-bo avatar Jun 19 '19 19:06 ma-bo