mirror of https://github.com/GNOME/gimp.git
app: Fix potential memory leak in save dialog code
Fix potential memory leak in save dialog code with a new helper function file_save_dialog_get_uri(). We must free zero-length strings.
This commit is contained in:
parent
2d1b3ddf72
commit
8033f4c0d5
|
@ -64,6 +64,7 @@ static gboolean file_save_dialog_check_uri (GtkWidget *save_di
|
|||
gchar **ret_uri,
|
||||
gchar **ret_basename,
|
||||
GimpPlugInProcedure **ret_save_proc);
|
||||
static gchar * file_save_dialog_get_uri (GimpFileDialog *dialog);
|
||||
static void file_save_dialog_unknown_ext_msg (GimpFileDialog *dialog,
|
||||
Gimp *gimp);
|
||||
static gboolean file_save_dialog_use_extension (GtkWidget *save_dialog,
|
||||
|
@ -212,9 +213,9 @@ file_save_dialog_check_uri (GtkWidget *save_dialog,
|
|||
GimpPlugInProcedure *uri_proc;
|
||||
GimpPlugInProcedure *basename_proc;
|
||||
|
||||
uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (save_dialog));
|
||||
uri = file_save_dialog_get_uri (dialog);
|
||||
|
||||
if (! (uri && strlen (uri)))
|
||||
if (! uri)
|
||||
return FALSE;
|
||||
|
||||
basename = file_utils_uri_display_basename (uri);
|
||||
|
@ -427,6 +428,20 @@ file_save_dialog_check_uri (GtkWidget *save_dialog,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
file_save_dialog_get_uri (GimpFileDialog *dialog)
|
||||
{
|
||||
gchar *uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
|
||||
|
||||
if (uri && ! strlen (uri))
|
||||
{
|
||||
g_free (uri);
|
||||
uri = NULL;
|
||||
}
|
||||
|
||||
return uri;
|
||||
}
|
||||
|
||||
static void
|
||||
file_save_dialog_unknown_ext_msg (GimpFileDialog *dialog,
|
||||
Gimp *gimp)
|
||||
|
|
Loading…
Reference in New Issue