Skip to content

Commit e627e37

Browse files
authored
Fix Valgrind warning (#1163)
Zero-terminate the result buffer after number conversion. Fixes: #1162
1 parent fb496c3 commit e627e37

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

quickjs.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3521,7 +3521,10 @@ static JSAtom js_atom_concat_str(JSContext *ctx, JSAtom name, const char *str1)
35213521
static JSAtom js_atom_concat_num(JSContext *ctx, JSAtom name, uint32_t n)
35223522
{
35233523
char buf[16];
3524-
u32toa(buf, n);
3524+
size_t len;
3525+
3526+
len = u32toa(buf, n);
3527+
buf[len] = '\0';
35253528
return js_atom_concat_str(ctx, name, buf);
35263529
}
35273530

0 commit comments

Comments
 (0)