From ffd9113cc52bd4e56770c14c8c6f2c049dd664f1 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 26 Sep 2025 19:35:34 +0200 Subject: [PATCH] Fix Valgrind warning Zero-terminate the result buffer after number conversion. Fixes: https://github.com/quickjs-ng/quickjs/issues/1162 --- quickjs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/quickjs.c b/quickjs.c index f63b7df66..40c5d5589 100644 --- a/quickjs.c +++ b/quickjs.c @@ -3521,7 +3521,10 @@ static JSAtom js_atom_concat_str(JSContext *ctx, JSAtom name, const char *str1) static JSAtom js_atom_concat_num(JSContext *ctx, JSAtom name, uint32_t n) { char buf[16]; - u32toa(buf, n); + size_t len; + + len = u32toa(buf, n); + buf[len] = '\0'; return js_atom_concat_str(ctx, name, buf); }