Do not leak path or use it after free.

This commit is contained in:
nicm
2018-07-31 13:06:44 +00:00
parent 82776c456e
commit 5f07da6227
2 changed files with 5 additions and 2 deletions

View File

@ -106,6 +106,8 @@ cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item)
flags = "ab";
file = server_client_get_path(c, path);
free(path);
f = fopen(file, flags);
if (f == NULL) {
cmdq_error(item, "%s: %s", file, strerror(errno));
@ -122,7 +124,6 @@ cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item)
fclose(f);
free(file);
free(path);
return (CMD_RETURN_NORMAL);