[gtk/wip/baedert/for-master: 172/180] filechooserwidget: Avoid an uninitialized value
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/for-master: 172/180] filechooserwidget: Avoid an uninitialized value
- Date: Fri, 16 Oct 2020 19:58:53 +0000 (UTC)
commit 8c400e972ae6da2f3be9119c272d7239d63c7f79
Author: Timm Bäder <mail baedert org>
Date: Thu Oct 15 06:57:13 2020 +0200
filechooserwidget: Avoid an uninitialized value
If the operation mode is OPERATION_MODE_RECENT and we end up in the
'goto file_entry' case, we don't set info.result. Then later after
calling check_save_entry, is_empty is TRUE which causes a goto out and
here we then try to use info.result, which is uninitialized.
Initialize info.result before doing all this.
Found by scan-build
gtk/gtkfilechooserwidget.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index 171301a24b..594a908e94 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -5395,6 +5395,10 @@ gtk_file_chooser_widget_get_files (GtkFileChooser *chooser)
if (impl->operation_mode == OPERATION_MODE_SEARCH)
return get_selected_files_as_model (impl);
+ info.impl = impl;
+ info.result = g_list_store_new (G_TYPE_FILE);
+ info.file_from_entry = NULL;
+
if (impl->operation_mode == OPERATION_MODE_RECENT)
{
if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
@@ -5403,13 +5407,12 @@ gtk_file_chooser_widget_get_files (GtkFileChooser *chooser)
goto file_entry;
}
else
- return get_selected_files_as_model (impl);
+ {
+ g_object_unref (info.result);
+ return get_selected_files_as_model (impl);
+ }
}
- info.impl = impl;
- info.result = g_list_store_new (G_TYPE_FILE);
- info.file_from_entry = NULL;
-
toplevel = get_toplevel (GTK_WIDGET (impl));
if (toplevel)
current_focus = gtk_root_get_focus (GTK_ROOT (toplevel));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]