From 42262a7c53cef75f17de52b76cfdbdd5daf5b4f7 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 29 Oct 2024 22:52:56 +0100 Subject: [PATCH] Don't segfault on missing line number data (#641) 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 62cf799..40f1842 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;