added SAFE_STACK flag

This commit is contained in:
2021-01-01 20:02:36 -06:00
parent 509823e1bc
commit be7a291ff2
2 changed files with 11 additions and 0 deletions

View File

@@ -90,10 +90,12 @@ void closeUpvalues(CState *state, CValue *local) {
}
void pushCallFrame(CState *state, CObjClosure *closure, int args) {
#ifdef SAFE_STACK
if (state->frameCount >= FRAME_MAX) {
cosmoV_error(state, "Callframe overflow!");
return;
}
#endif
CCallFrame *frame = &state->callFrame[state->frameCount++];
frame->base = state->top - args - 1; // - 1 for the function