mirror of
https://github.com/tmate-io/tmate.git
synced 2025-02-23 22:00:59 +01:00
Terminate strftime buffer properly and free format string, whoops. From
Tiago Cunha.
This commit is contained in:
parent
f4fdddc930
commit
8b68ea1462
@ -51,6 +51,7 @@ cmd_display_message_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||
struct format_tree *ft;
|
||||
char out[BUFSIZ];
|
||||
time_t t;
|
||||
size_t len;
|
||||
|
||||
if ((c = cmd_find_client(ctx, args_get(args, 'c'))) == NULL)
|
||||
return (-1);
|
||||
@ -83,14 +84,16 @@ cmd_display_message_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||
format_window_pane(ft, wp);
|
||||
|
||||
t = time(NULL);
|
||||
strftime(out, sizeof out, template, localtime(&t));
|
||||
len = strftime(out, sizeof out, template, localtime(&t));
|
||||
out[len] = '\0';
|
||||
|
||||
msg = format_expand(ft, out);
|
||||
if (args_has(self->args, 'p'))
|
||||
ctx->print(ctx, "%s", msg);
|
||||
else
|
||||
status_message_set(c, "%s", msg);
|
||||
xfree(msg);
|
||||
|
||||
xfree(msg);
|
||||
format_free(ft);
|
||||
return (0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user