diff options
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sway/commands.c b/sway/commands.c index fdae1961..81e9ea42 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -511,11 +511,14 @@ struct cmd_results *cmd_results_new(enum cmd_status status, results->input = NULL; } if (format) { - char *error = malloc(256); va_list args; va_start(args, format); + size_t length = vsnprintf(NULL, 0, format, args) + 1; + char *error = malloc(length); + va_end(args); + va_start(args, format); if (error) { - vsnprintf(error, 256, format, args); + vsnprintf(error, length, format, args); } va_end(args); results->error = error; |