|
|
3a204fb |
From e1cdcccab0a3861d0c465cb4b75fede605a7ec17 Mon Sep 17 00:00:00 2001
|
|
|
3a204fb |
From: Jakub Filak <jfilak@redhat.com>
|
|
|
3a204fb |
Date: Sun, 25 Jan 2015 14:19:43 +0100
|
|
|
3a204fb |
Subject: [PATCH] fix several memory leaks
|
|
|
3a204fb |
|
|
|
3a204fb |
I discovered these leaks while chasing a bug related to rhbz#1163579.
|
|
|
3a204fb |
|
|
|
3a204fb |
The most interesting one is the missing semicolon in src/lib/file_obj.c
|
|
|
3a204fb |
|
|
|
3a204fb |
Signed-off-by: Jakub Filak <jfilak@redhat.com>
|
|
|
3a204fb |
---
|
|
|
3a204fb |
src/gtk-helpers/problem_details_widget.c | 1 +
|
|
|
3a204fb |
src/gui-wizard-gtk/main.c | 7 ++++---
|
|
|
3a204fb |
src/gui-wizard-gtk/wizard.c | 10 +++++++---
|
|
|
3a204fb |
src/lib/file_obj.c | 4 ++--
|
|
|
3a204fb |
src/lib/workflow.c | 4 +++-
|
|
|
3a204fb |
5 files changed, 17 insertions(+), 9 deletions(-)
|
|
|
3a204fb |
|
|
|
3a204fb |
diff --git a/src/gtk-helpers/problem_details_widget.c b/src/gtk-helpers/problem_details_widget.c
|
|
|
3a204fb |
index c314d4d..fed65b2 100644
|
|
|
3a204fb |
--- a/src/gtk-helpers/problem_details_widget.c
|
|
|
3a204fb |
+++ b/src/gtk-helpers/problem_details_widget.c
|
|
|
3a204fb |
@@ -305,6 +305,7 @@ problem_details_widget_populate(ProblemDetailsWidget *self)
|
|
|
3a204fb |
line = xasprintf("%s", uid ? uid : username);
|
|
|
3a204fb |
|
|
|
3a204fb |
problem_details_widget_add_single_line(self, "user", line);
|
|
|
3a204fb |
+ free(line);
|
|
|
3a204fb |
}
|
|
|
3a204fb |
|
|
|
3a204fb |
{ /* Type/Analyzer: CCpp */
|
|
|
3a204fb |
diff --git a/src/gui-wizard-gtk/main.c b/src/gui-wizard-gtk/main.c
|
|
|
3a204fb |
index 41a8089..9780c8d 100644
|
|
|
3a204fb |
--- a/src/gui-wizard-gtk/main.c
|
|
|
3a204fb |
+++ b/src/gui-wizard-gtk/main.c
|
|
|
3a204fb |
@@ -195,9 +195,9 @@ int main(int argc, char **argv)
|
|
|
3a204fb |
load_workflow_config_data(WORKFLOWS_DIR);
|
|
|
3a204fb |
|
|
|
3a204fb |
/* list of workflows applicable to the currently processed problem */
|
|
|
3a204fb |
- GHashTable *possible_workflows = load_workflow_config_data_from_list(
|
|
|
3a204fb |
- list_possible_events_glist(g_dump_dir_name, "workflow"),
|
|
|
3a204fb |
- WORKFLOWS_DIR);
|
|
|
3a204fb |
+ GList *possible_names = list_possible_events_glist(g_dump_dir_name, "workflow");
|
|
|
3a204fb |
+ GHashTable *possible_workflows = load_workflow_config_data_from_list(possible_names, WORKFLOWS_DIR);
|
|
|
3a204fb |
+ g_list_free_full(possible_names, free);
|
|
|
3a204fb |
|
|
|
3a204fb |
/* if we have only 1 workflow, we can use the events from it as default */
|
|
|
3a204fb |
if (!expert_mode && g_auto_event_list == NULL && g_hash_table_size(possible_workflows) == 1)
|
|
|
3a204fb |
@@ -212,6 +212,7 @@ int main(int argc, char **argv)
|
|
|
3a204fb |
g_auto_event_list = wf_get_event_names((workflow_t *)value);
|
|
|
3a204fb |
}
|
|
|
3a204fb |
}
|
|
|
3a204fb |
+ g_hash_table_destroy(possible_workflows);
|
|
|
3a204fb |
|
|
|
3a204fb |
problem_data_reload_from_dump_dir();
|
|
|
3a204fb |
|
|
|
3a204fb |
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
|
|
|
3a204fb |
index ab6123f..513f0a3 100644
|
|
|
3a204fb |
--- a/src/gui-wizard-gtk/wizard.c
|
|
|
3a204fb |
+++ b/src/gui-wizard-gtk/wizard.c
|
|
|
3a204fb |
@@ -2424,14 +2424,14 @@ static bool highligh_words_in_textview(int page, GtkTextView *tev, GList *words,
|
|
|
3a204fb |
SEARCH_COLUMN_ITEM, &word,
|
|
|
3a204fb |
-1);
|
|
|
3a204fb |
|
|
|
3a204fb |
+ free(text);
|
|
|
3a204fb |
+
|
|
|
3a204fb |
if (word->buffer == buffer)
|
|
|
3a204fb |
{
|
|
|
3a204fb |
buffer_removing = true;
|
|
|
3a204fb |
|
|
|
3a204fb |
valid = gtk_list_store_remove(g_ls_sensitive_list, &iter);
|
|
|
3a204fb |
|
|
|
3a204fb |
- free(text);
|
|
|
3a204fb |
-
|
|
|
3a204fb |
if (word == g_current_highlighted_word)
|
|
|
3a204fb |
g_current_highlighted_word = NULL;
|
|
|
3a204fb |
|
|
|
3a204fb |
@@ -2794,9 +2794,12 @@ static void add_workflow_buttons(GtkBox *box, GHashTable *workflows, GCallback f
|
|
|
3a204fb |
{
|
|
|
3a204fb |
gtk_container_foreach(GTK_CONTAINER(box), &remove_child_widget, NULL);
|
|
|
3a204fb |
|
|
|
3a204fb |
+ GList *possible_workflows = list_possible_events_glist(g_dump_dir_name, "workflow");
|
|
|
3a204fb |
GHashTable *workflow_table = load_workflow_config_data_from_list(
|
|
|
3a204fb |
- list_possible_events_glist(g_dump_dir_name, "workflow"),
|
|
|
3a204fb |
+ possible_workflows,
|
|
|
3a204fb |
WORKFLOWS_DIR);
|
|
|
3a204fb |
+ g_list_free_full(possible_workflows, free);
|
|
|
3a204fb |
+ g_object_set_data_full(G_OBJECT(box), "workflows", workflow_table, (GDestroyNotify)g_hash_table_destroy);
|
|
|
3a204fb |
|
|
|
3a204fb |
GList *wf_list = g_hash_table_get_values(workflow_table);
|
|
|
3a204fb |
wf_list = g_list_sort(wf_list, (GCompareFunc)wf_priority_compare);
|
|
|
3a204fb |
@@ -2817,6 +2820,7 @@ static void add_workflow_buttons(GtkBox *box, GHashTable *workflows, GCallback f
|
|
|
3a204fb |
gtk_widget_set_margin_start(label, 40);
|
|
|
3a204fb |
#endif
|
|
|
3a204fb |
gtk_widget_set_margin_bottom(label, 10);
|
|
|
3a204fb |
+ g_list_free(children);
|
|
|
3a204fb |
free(btn_label);
|
|
|
3a204fb |
g_signal_connect(button, "clicked", func, w);
|
|
|
3a204fb |
gtk_box_pack_start(box, button, true, false, 2);
|
|
|
3a204fb |
diff --git a/src/lib/file_obj.c b/src/lib/file_obj.c
|
|
|
3a204fb |
index bbb5b9f..0821155 100644
|
|
|
3a204fb |
--- a/src/lib/file_obj.c
|
|
|
3a204fb |
+++ b/src/lib/file_obj.c
|
|
|
3a204fb |
@@ -30,7 +30,7 @@ file_obj_t *new_file_obj(const char* fullpath, const char* filename)
|
|
|
3a204fb |
void free_file_obj(file_obj_t *f)
|
|
|
3a204fb |
{
|
|
|
3a204fb |
if (f == NULL)
|
|
|
3a204fb |
- return
|
|
|
3a204fb |
+ return;
|
|
|
3a204fb |
|
|
|
3a204fb |
free(f->fullpath);
|
|
|
3a204fb |
free(f->filename);
|
|
|
3a204fb |
@@ -45,4 +45,4 @@ const char *fo_get_fullpath(file_obj_t *fo)
|
|
|
3a204fb |
const char *fo_get_filename(file_obj_t *fo)
|
|
|
3a204fb |
{
|
|
|
3a204fb |
return fo->filename;
|
|
|
3a204fb |
-}
|
|
|
3a204fb |
\ No newline at end of file
|
|
|
3a204fb |
+}
|
|
|
3a204fb |
diff --git a/src/lib/workflow.c b/src/lib/workflow.c
|
|
|
3a204fb |
index c6eedf4..a985834 100644
|
|
|
3a204fb |
--- a/src/lib/workflow.c
|
|
|
3a204fb |
+++ b/src/lib/workflow.c
|
|
|
3a204fb |
@@ -90,7 +90,7 @@ static void load_workflow_config(const char *name,
|
|
|
3a204fb |
workflow_t *workflow = new_workflow(file->filename);
|
|
|
3a204fb |
load_workflow_description_from_file(workflow, file->fullpath);
|
|
|
3a204fb |
log_notice("Adding '%s' to workflows\n", file->filename);
|
|
|
3a204fb |
- g_hash_table_insert(wf_list, file->filename, workflow);
|
|
|
3a204fb |
+ g_hash_table_insert(wf_list, xstrdup(file->filename), workflow);
|
|
|
3a204fb |
}
|
|
|
3a204fb |
}
|
|
|
3a204fb |
|
|
|
3a204fb |
@@ -104,12 +104,14 @@ GHashTable *load_workflow_config_data_from_list(GList *wf_names,
|
|
|
3a204fb |
g_free,
|
|
|
3a204fb |
(GDestroyNotify) free_workflow
|
|
|
3a204fb |
);
|
|
|
3a204fb |
+
|
|
|
3a204fb |
GList *workflow_files = get_file_list(path, "xml");
|
|
|
3a204fb |
while(wfs)
|
|
|
3a204fb |
{
|
|
|
3a204fb |
load_workflow_config((const char *)wfs->data, workflow_files, wf_list);
|
|
|
3a204fb |
wfs = g_list_next(wfs);
|
|
|
3a204fb |
}
|
|
|
3a204fb |
+ free_file_list(workflow_files);
|
|
|
3a204fb |
|
|
|
3a204fb |
return wf_list;
|
|
|
3a204fb |
}
|
|
|
3a204fb |
--
|
|
|
3a204fb |
2.1.0
|
|
|
3a204fb |
|