** Get the number of extra arguments in a vararg function. If vararg ** table has been optimized away, that number is in the call info. ** Otherwise, get the field 'n' from the vararg table and check that it ** has a proper value (non-negative integer not larger than the stack ** limit). */
| 319 | ** limit). |
| 320 | */ |
| 321 | static int getnumargs (lua_State *L, CallInfo *ci, Table *h) { |
| 322 | if (h == NULL) /* no vararg table? */ |
| 323 | return ci->u.l.nextraargs; |
| 324 | else { |
| 325 | TValue res; |
| 326 | if (luaH_getshortstr(h, luaS_new(L, "n"), &res) != LUA_VNUMINT || |
| 327 | l_castS2U(ivalue(&res)) > cast_uint(INT_MAX/2)) |
| 328 | luaG_runerror(L, "vararg table has no proper 'n'"); |
| 329 | return cast_int(ivalue(&res)); |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | |
| 334 | /* |
no test coverage detected