diff --git a/ce/ce.c b/ce/ce.c index e1f07dd..1bb3bd8 100644 --- a/ce/ce.c +++ b/ce/ce.c @@ -58,11 +58,15 @@ void cprintf (struct context* context, const char* fmt, ...) { return; } - vsnprintf (buf, CPRINTF_BUF_MAX, fmt, args); + int len = vsnprintf (buf, CPRINTF_BUF_MAX, fmt, 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); } @@ -492,7 +496,7 @@ static void execute_redir (struct ast_redir* redir, struct context* context) { } 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 (); }