|
|
87befbd |
From cb2ab9a8b2e1dbc89e100aedc432c29a16246e84 Mon Sep 17 00:00:00 2001
|
|
|
87befbd |
From: =?UTF-8?q?Mat=C4=9Bj=20Grabovsk=C3=BD?= <mgrabovs@redhat.com>
|
|
|
87befbd |
Date: Sun, 27 Sep 2020 20:45:32 +0200
|
|
|
87befbd |
Subject: [PATCH] gui-wizard-gtk: Fix a segfault and memory leak
|
|
|
87befbd |
|
|
|
87befbd |
Only `arg[1]` has to be freed in `tv_details_row_activated()`, as
|
|
|
87befbd |
`arg[0]` is allocated statically.
|
|
|
87befbd |
|
|
|
87befbd |
In `search_item_to_list_store_item()`, `tmp` gets overwritten with a new
|
|
|
87befbd |
value for every call to `gtk_text_buffer_get_text()`, so we need to free
|
|
|
87befbd |
the allocated memory continuously.
|
|
|
87befbd |
|
|
|
87befbd |
Partially reverts 7aba6e53.
|
|
|
87befbd |
|
|
|
87befbd |
Resolves rhbz#1882950
|
|
|
87befbd |
---
|
|
|
87befbd |
src/gui-wizard-gtk/wizard.c | 9 +++++++--
|
|
|
87befbd |
1 file changed, 7 insertions(+), 2 deletions(-)
|
|
|
87befbd |
|
|
|
87befbd |
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
|
|
|
87befbd |
index a532c633..775b709f 100644
|
|
|
87befbd |
--- a/src/gui-wizard-gtk/wizard.c
|
|
|
87befbd |
+++ b/src/gui-wizard-gtk/wizard.c
|
|
|
87befbd |
@@ -707,7 +707,7 @@ static void tv_details_row_activated(
|
|
|
87befbd |
return;
|
|
|
87befbd |
|
|
|
87befbd |
gint exitcode;
|
|
|
87befbd |
- g_autofree gchar *arg[3];
|
|
|
87befbd |
+ gchar *arg[3];
|
|
|
87befbd |
arg[0] = (char *) "xdg-open";
|
|
|
87befbd |
arg[1] = g_build_filename(g_dump_dir_name ? g_dump_dir_name : "", item_name, NULL);
|
|
|
87befbd |
arg[2] = NULL;
|
|
|
87befbd |
@@ -751,6 +751,8 @@ static void tv_details_row_activated(
|
|
|
87befbd |
gtk_widget_destroy(scrolled);
|
|
|
87befbd |
gtk_widget_destroy(dialog);
|
|
|
87befbd |
}
|
|
|
87befbd |
+
|
|
|
87befbd |
+ g_free(arg[1]);
|
|
|
87befbd |
}
|
|
|
87befbd |
|
|
|
87befbd |
/* static gboolean tv_details_select_cursor_row(
|
|
|
87befbd |
@@ -2126,17 +2128,20 @@ static void search_item_to_list_store_item(GtkListStore *store, GtkTreeIter *new
|
|
|
87befbd |
gtk_text_iter_backward_char(end);
|
|
|
87befbd |
}
|
|
|
87befbd |
|
|
|
87befbd |
- g_autofree gchar *tmp = gtk_text_buffer_get_text(word->buffer, beg, &(word->start),
|
|
|
87befbd |
+ gchar *tmp = gtk_text_buffer_get_text(word->buffer, beg, &(word->start),
|
|
|
87befbd |
/*don't include hidden chars*/FALSE);
|
|
|
87befbd |
g_autofree gchar *prefix = g_markup_escape_text(tmp, /*NULL terminated string*/-1);
|
|
|
87befbd |
+ g_free(tmp);
|
|
|
87befbd |
|
|
|
87befbd |
tmp = gtk_text_buffer_get_text(word->buffer, &(word->start), &(word->end),
|
|
|
87befbd |
/*don't include hidden chars*/FALSE);
|
|
|
87befbd |
g_autofree gchar *text = g_markup_escape_text(tmp, /*NULL terminated string*/-1);
|
|
|
87befbd |
+ g_free(tmp);
|
|
|
87befbd |
|
|
|
87befbd |
tmp = gtk_text_buffer_get_text(word->buffer, &(word->end), end,
|
|
|
87befbd |
/*don't include hidden chars*/FALSE);
|
|
|
87befbd |
g_autofree gchar *suffix = g_markup_escape_text(tmp, /*NULL terminated string*/-1);
|
|
|
87befbd |
+ g_clear_pointer(&tmp, g_free);
|
|
|
87befbd |
|
|
|
87befbd |
char *content = g_strdup_printf("%s%s%s", prefix, text, suffix);
|
|
|
87befbd |
|
|
|
87befbd |
--
|
|
|
87befbd |
2.26.2
|
|
|
87befbd |
|