mirror of
https://github.com/CPunch/Cosmo.git
synced 2024-11-22 07:20:05 +00:00
moved the results cap check in callCFunction
This commit is contained in:
parent
eede892eb0
commit
b2c1f73e01
@ -117,14 +117,14 @@ static inline void callCFunction(CState *state, CosmoCFunction cfunc, int args,
|
|||||||
int nres = cfunc(state, args, savedBase + 1);
|
int nres = cfunc(state, args, savedBase + 1);
|
||||||
cosmoM_unfreezeGC(state);
|
cosmoM_unfreezeGC(state);
|
||||||
|
|
||||||
|
if (nres > nresults) // caller function wasn't expecting this many return values, cap it
|
||||||
|
nres = nresults;
|
||||||
|
|
||||||
// remember where the return values are
|
// remember where the return values are
|
||||||
CValue* results = cosmoV_getTop(state, nres-1);
|
CValue* results = cosmoV_getTop(state, nres-1);
|
||||||
|
|
||||||
state->top = savedBase + offset; // set stack
|
state->top = savedBase + offset; // set stack
|
||||||
|
|
||||||
if (nres > nresults) // caller function wasn't expecting this many return values, cap it
|
|
||||||
nres = nresults;
|
|
||||||
|
|
||||||
// push the return value back onto the stack
|
// push the return value back onto the stack
|
||||||
memcpy(state->top, results, sizeof(CValue) * nres); // copies the return values to the top of the stack
|
memcpy(state->top, results, sizeof(CValue) * nres); // copies the return values to the top of the stack
|
||||||
state->top += nres; // and make sure to move state->top to match
|
state->top += nres; // and make sure to move state->top to match
|
||||||
|
Loading…
Reference in New Issue
Block a user