aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeandro Pereira <leandro@hardinfo.org>2012-01-27 08:07:01 -0200
committerLeandro Pereira <leandro@hardinfo.org>2012-01-27 08:07:01 -0200
commit204118eff1c73234d89be9530226208a3ccb9f03 (patch)
tree8dd4a9c0eeee240400852304a3f5b14a24fcf087
parent04dae1597ecc3b0b4eddff34da73a6a9b1c0a7c4 (diff)
Cleanups in report.c
-rw-r--r--shell/report.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/shell/report.c b/shell/report.c
index fb18c346..20974de1 100644
--- a/shell/report.c
+++ b/shell/report.c
@@ -111,8 +111,18 @@ void report_context_configure(ReportContext * ctx, GKeyFile * keyfile)
if (g_str_equal(key, "ShowColumnHeaders")) {
ctx->show_column_headers = g_key_file_get_boolean(keyfile, group, key, NULL);
} else if (g_str_has_prefix(key, "ColumnTitle")) {
- gchar *value, *title = strchr(key, '$') + 1;
+ gchar *value, *title = strchr(key, '$');
+ if (!title) {
+ DEBUG("couldn't find column title");
+ break;
+ }
+ title++;
+ if (!*title) {
+ DEBUG("title is empty");
+ break;
+ }
+
value = g_key_file_get_value(keyfile, group, key, NULL);
if (g_str_equal(title, "Extra1")) {
ctx->columns |= REPORT_COL_EXTRA1;
@@ -126,9 +136,7 @@ void report_context_configure(ReportContext * ctx, GKeyFile * keyfile)
ctx->columns |= REPORT_COL_PROGRESS;
}
- g_hash_table_replace(ctx->column_titles, title, g_strdup(value));
-
- g_free(value);
+ g_hash_table_replace(ctx->column_titles, title, 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;