From 3974eaebe657b989ce55a85fc24bc7fd09e67c00 Mon Sep 17 00:00:00 2001 From: Jeinzi Date: Sat, 1 Sep 2018 03:33:33 +0200 Subject: Fixed several memory leaks. --- src/binds.c | 3 ++- src/imv.c | 9 ++++++++- src/list.c | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src') 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) -- cgit v1.2.3