mirror of
https://github.com/tmux/tmux.git
synced 2025-01-07 16:28:48 +00:00
Do not leak path or use it after free.
This commit is contained in:
parent
82776c456e
commit
5f07da6227
@ -85,7 +85,7 @@ cmd_load_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
error = server_set_stdin_callback(c, cmd_load_buffer_callback,
|
error = server_set_stdin_callback(c, cmd_load_buffer_callback,
|
||||||
cdata, &cause);
|
cdata, &cause);
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
cmdq_error(item, "%s: %s", path, cause);
|
cmdq_error(item, "-: %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
@ -93,6 +93,8 @@ cmd_load_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
}
|
}
|
||||||
|
|
||||||
file = server_client_get_path(c, path);
|
file = server_client_get_path(c, path);
|
||||||
|
free(path);
|
||||||
|
|
||||||
f = fopen(file, "rb");
|
f = fopen(file, "rb");
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
cmdq_error(item, "%s: %s", file, strerror(errno));
|
cmdq_error(item, "%s: %s", file, strerror(errno));
|
||||||
|
@ -106,6 +106,8 @@ cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
flags = "ab";
|
flags = "ab";
|
||||||
|
|
||||||
file = server_client_get_path(c, path);
|
file = server_client_get_path(c, path);
|
||||||
|
free(path);
|
||||||
|
|
||||||
f = fopen(file, flags);
|
f = fopen(file, flags);
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
cmdq_error(item, "%s: %s", file, strerror(errno));
|
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);
|
fclose(f);
|
||||||
free(file);
|
free(file);
|
||||||
free(path);
|
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user