summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-11-02 19:34:01 +0100
committerJo-Philipp Wich <jo@mein.io>2020-11-02 19:43:03 +0100
commitf23fb27f949f28517bef5206a5773f08d8202ea8 (patch)
treebe36a6286b02eeda9f07dfb47b3d768118100117
parent5fb260f1fcd302cb529bec52520345c77bbbadf8 (diff)
ast: avoid null pointer deref in ut_new_exception()
When reporting parse errors, we might not have a function context so avoid dereferencing it without checking. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--ast.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/ast.c b/ast.c
index 4818ee9..1a7355a 100644
--- a/ast.c
+++ b/ast.c
@@ -426,7 +426,7 @@ ut_new_exception(struct ut_state *s, uint32_t off, const char *fmt, ...)
for (callstack = &here, prevcall = NULL; callstack != NULL;
prevcall = callstack, callstack = callstack->next)
- if (callstack->off && callstack->function->source &&
+ if (callstack->off && callstack->function && callstack->function->source &&
(!prevcall || callstack->function != prevcall->function || callstack->off != prevcall->off))
add_stacktrace(a, callstack->function, callstack->off);