aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeinzi <Jeinzi@gmx.de>2018-09-01 03:33:33 +0200
committerJeinzi <Jeinzi@gmx.de>2018-09-01 03:33:33 +0200
commit3974eaebe657b989ce55a85fc24bc7fd09e67c00 (patch)
tree9c61933fd5aeb8c001d5c7cf759ba9049eea38ab
parentb5e646615e42a1f6991c7424c639faf2c4b49d52 (diff)
downloadimv-3974eaebe657b989ce55a85fc24bc7fd09e67c00.tar.gz
Fixed several memory leaks.
-rw-r--r--src/binds.c3
-rw-r--r--src/imv.c9
-rw-r--r--src/list.c1
3 files changed, 11 insertions, 2 deletions
diff --git a/src/binds.c b/src/binds.c
index a710278..9e268b4 100644
--- a/src/binds.c
+++ b/src/binds.c
@@ -51,6 +51,7 @@ struct imv_binds *imv_binds_create(void)
void imv_binds_free(struct imv_binds *binds)
{
destroy_bind_node(&binds->bind_tree);
+ list_deep_free(binds->keys);
free(binds);
}
@@ -83,7 +84,7 @@ enum bind_result imv_binds_add(struct imv_binds *binds, const struct list *keys,
/* Create our new node */
next_node = malloc(sizeof(struct bind_node));
init_bind_node(next_node);
- next_node->key = strdup(keys->items[i]);
+ next_node->key = keys->items[i];
list_append(node->suffixes, next_node);
} else {
next_node = node->suffixes->items[child_index];
diff --git a/src/imv.c b/src/imv.c
index 768ae21..674283f 100644
--- a/src/imv.c
+++ b/src/imv.c
@@ -129,6 +129,7 @@ static const char *add_bind(struct imv *imv, const char *keys, const char *comma
}
enum bind_result result = imv_binds_add(imv->binds, list, command);
+ list_free(list);
if (result == BIND_SUCCESS) {
return NULL;
@@ -244,10 +245,14 @@ struct imv *imv_create(void)
void imv_free(struct imv *imv)
{
free(imv->font_name);
+ free(imv->title_text);
+ free(imv->overlay_text);
imv_binds_free(imv->binds);
imv_navigator_free(imv->navigator);
imv_loader_free(imv->loader);
imv_commands_free(imv->commands);
+ imv_viewport_free(imv->view);
+ imv_image_free(imv->image);
if(imv->stdin_image_data) {
free(imv->stdin_image_data);
}
@@ -928,6 +933,7 @@ static char *get_config_path(void)
wordexp_t word;
if(wordexp(config_paths[i], &word, 0) == 0) {
if (!word.we_wordv[0]) {
+ wordfree(&word);
continue;
}
@@ -1073,7 +1079,7 @@ static int handle_ini_value(void *user, const char *section, const char *name,
bool imv_load_config(struct imv *imv)
{
- const char *path = get_config_path();
+ char *path = get_config_path();
if(!path) {
/* no config, no problem - we have defaults */
return true;
@@ -1087,6 +1093,7 @@ bool imv_load_config(struct imv *imv)
fprintf(stderr, "Error in config file: %s:%d\n", path, err);
return false;
}
+ free(path);
return true;
}
diff --git a/src/list.c b/src/list.c
index 0bc3b7e..4cd7f24 100644
--- a/src/list.c
+++ b/src/list.c
@@ -12,6 +12,7 @@ struct list *list_create(void)
void list_free(struct list *list)
{
free(list->items);
+ free(list);
}
void list_deep_free(struct list *list)