added maximum nested call limit
This commit is contained in:
@@ -1,4 +1,9 @@
|
|||||||
|
|
||||||
|
fun k(k)
|
||||||
|
return k();
|
||||||
|
|
||||||
|
k(k);
|
||||||
|
|
||||||
fun x(a, b, c)
|
fun x(a, b, c)
|
||||||
print(a, b, c);
|
print(a, b, c);
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "runtime.h"
|
#include "runtime.h"
|
||||||
|
|
||||||
#define MAX_FRAME_STACK 16
|
#define MAX_FRAME_STACK 16
|
||||||
|
#define MAX_FRAMES 1024
|
||||||
|
|
||||||
typedef struct Frame Frame;
|
typedef struct Frame Frame;
|
||||||
|
|
||||||
@@ -674,6 +675,14 @@ Object *run(Runtime *runtime, Error *error, Executable *exe, int index, Object *
|
|||||||
assert(exe != NULL);
|
assert(exe != NULL);
|
||||||
assert(index >= 0);
|
assert(index >= 0);
|
||||||
assert(argc >= 0);
|
assert(argc >= 0);
|
||||||
|
|
||||||
|
if(runtime->depth == MAX_FRAMES)
|
||||||
|
{
|
||||||
|
Error_Report(error, 1, "Maximum nested call limit of %d was reached", MAX_FRAMES);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(runtime->depth < MAX_FRAMES);
|
||||||
|
|
||||||
// Initialize the frame.
|
// Initialize the frame.
|
||||||
Frame frame;
|
Frame frame;
|
||||||
|
|||||||
Reference in New Issue
Block a user