summaryrefslogtreecommitdiffhomepage
path: root/ast.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-10-18 18:06:54 +0200
committerJo-Philipp Wich <jo@mein.io>2020-10-18 18:09:21 +0200
commit898a28de86600b62ddd5f971b910eaadc222bbb7 (patch)
tree7d4e18f136e50517f154c372f057937f1992ee77 /ast.c
parentd815d0e0ee00de41e792246ba1baddf1d68b0f59 (diff)
ast, eval: add recursion limit
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'ast.c')
-rw-r--r--ast.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/ast.c b/ast.c
index 72fa6e9..2e1c169 100644
--- a/ast.c
+++ b/ast.c
@@ -405,7 +405,7 @@ add_stacktrace(struct json_object *a, struct ut_source *source, const char *func
__attribute__((format(printf, 3, 4))) struct json_object *
ut_new_exception(struct ut_state *s, uint32_t off, const char *fmt, ...)
{
- struct ut_callstack *callstack;
+ struct ut_callstack *callstack, *prevcall;
struct json_object *a;
struct ut_op *op;
va_list ap;
@@ -425,8 +425,11 @@ ut_new_exception(struct ut_state *s, uint32_t off, const char *fmt, ...)
s->function ? s->function->name : NULL,
off);
- for (callstack = s->callstack ? s->callstack->next : NULL; callstack; callstack = callstack->next)
- if (callstack->off)
+ for (callstack = s->callstack ? s->callstack->next : NULL, prevcall = NULL;
+ callstack != NULL;
+ prevcall = callstack, callstack = callstack->next)
+ if (callstack->off &&
+ (!prevcall || callstack->source != prevcall->source || callstack->off != prevcall->off))
add_stacktrace(a, callstack->source, callstack->funcname, callstack->off);
json_object_object_add(op->val, "stacktrace", a);