From 4fbce79521457be14ca4af385368495442daa11e Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 24 Oct 2024 09:09:40 +0200 Subject: [PATCH] Fix UndefinedBehaviorSanitizer error UBSan is right to complain that `s->ptr_last == NULL` when tracing is disabled. --- quickjs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/quickjs.c b/quickjs.c index 8573578..892a05c 100644 --- a/quickjs.c +++ b/quickjs.c @@ -35019,7 +35019,8 @@ static JSValue JS_ReadFunctionTag(BCReaderState *s) goto fail; if (b->source_len) { bc_read_trace(s, "source: %d bytes\n", b->source_len); - s->ptr_last += b->source_len; // omit source code hex dump + if (s->ptr_last) + s->ptr_last += b->source_len; // omit source code hex dump /* b->source is a UTF-8 encoded null terminated C string */ b->source = js_mallocz(ctx, b->source_len + 1); if (!b->source)