From 1ecd7c92fbbd83d74a1e9f6b921eeb82e13585c1 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 29 Oct 2024 21:25:30 +0100 Subject: [PATCH] Don't segfault on missing line number data Can be reproduced on the CLI but not from a script: # should throw "unsupported object class" TypeError $ qjs --std -e 'bjson.write(function(){})' /path/to/quickjs.c:6510:15: runtime error: applying zero offset to null pointer --- quickjs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/quickjs.c b/quickjs.c index 62cf79911..40f1842f1 100644 --- a/quickjs.c +++ b/quickjs.c @@ -6507,6 +6507,8 @@ static int find_line_num(JSContext *ctx, JSFunctionBytecode *b, *col = 1; p = b->pc2line_buf; + if (!p) + goto fail; p_end = p + b->pc2line_len; pc = 0; line_num = b->line_num;