CE fix amout of chars printed to file in redirection

This commit is contained in:
2026-03-01 14:10:36 +01:00
parent a4c485587e
commit 6313191b9b

10
ce/ce.c
View File

@@ -58,11 +58,15 @@ void cprintf (struct context* context, const char* fmt, ...) {
return; return;
} }
vsnprintf (buf, CPRINTF_BUF_MAX, fmt, args); int len = vsnprintf (buf, CPRINTF_BUF_MAX, fmt, args);
va_end (args); va_end (args);
strbuf_append_str (&context->strbuf, buf); if (len > 0) {
for (int i = 0; i < len; i++)
strbuf_append (&context->strbuf, buf[i]);
}
free (buf); free (buf);
} }
@@ -492,7 +496,7 @@ static void execute_redir (struct ast_redir* redir, struct context* context) {
} }
create_file (path); create_file (path);
write_file (path, 0, (uint8_t*)context->strbuf.items, context->strbuf.count); write_file (path, 0, (uint8_t*)context->strbuf.items, context->strbuf.count - 1);
volume_close (); volume_close ();
} }