Skip to content

Commit 179dade

Browse files
fix buffer print ub
1 parent d60fdbf commit 179dade

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

examples/llama-bench/llama-bench.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,8 @@ struct markdown_printer : public printer {
13841384
snprintf(buf, sizeof(buf), "pp%d+tg%d", t.n_prompt, t.n_gen);
13851385
}
13861386
if (t.n_depth > 0) {
1387-
snprintf(buf, sizeof(buf), "%s @ d%d", buf, t.n_depth);
1387+
int len = strlen(buf);
1388+
snprintf(buf + len, sizeof(buf) - len, " @ d%d", t.n_depth);
13881389
}
13891390
value = buf;
13901391
} else if (field == "t/s") {

0 commit comments

Comments
 (0)