aboutsummaryrefslogtreecommitdiff
path: root/shell/report.c
diff options
context:
space:
mode:
authorLeandro Pereira <leandro@hardinfo.org>2016-11-25 11:51:41 -0800
committerLeandro Pereira <leandro@hardinfo.org>2016-11-25 11:51:41 -0800
commitf409242d3e01a57f7f61bbdb2d1d041f08d291ab (patch)
tree2e3645ef7f83fb35de9a7eda667c942b0ad760a5 /shell/report.c
parent8e65e4ce85b29fa62ffe31a67358b59da8cc7944 (diff)
Fix use after free while generating reports
Found with AddressSanitizer.
Diffstat (limited to 'shell/report.c')
-rw-r--r--shell/report.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/shell/report.c b/shell/report.c
index 0259799e..d3fb5b9b 100644
--- a/shell/report.c
+++ b/shell/report.c
@@ -136,7 +136,8 @@ void report_context_configure(ReportContext * ctx, GKeyFile * keyfile)
ctx->columns |= REPORT_COL_PROGRESS;
}
- g_hash_table_replace(ctx->column_titles, title, value);
+ g_hash_table_replace(ctx->column_titles,
+ g_strdup(title), g_strdup(value));
} else if (g_str_equal(key, "ViewType")) {
if (g_key_file_get_integer(keyfile, group, "ViewType", NULL) == SHELL_VIEW_PROGRESS) {
ctx->columns &= ~REPORT_COL_VALUE;
@@ -526,7 +527,8 @@ ReportContext *report_context_html_new()
ctx->output = g_strdup("");
ctx->format = REPORT_FORMAT_HTML;
- ctx->column_titles = g_hash_table_new(g_str_hash, g_str_equal);
+ ctx->column_titles = g_hash_table_new_full(g_str_hash, g_str_equal,
+ g_free, g_free);
ctx->first_table = TRUE;
return ctx;
@@ -547,7 +549,8 @@ ReportContext *report_context_text_new()
ctx->output = g_strdup("");
ctx->format = REPORT_FORMAT_TEXT;
- ctx->column_titles = g_hash_table_new(g_str_hash, g_str_equal);
+ ctx->column_titles = g_hash_table_new_full(g_str_hash, g_str_equal,
+ g_free, g_free);
ctx->first_table = TRUE;
return ctx;