commit c986621b3f5d6e7910338718a12b537a244c705d
parent 0fc77dc8c5a8f789dac30489a8afb2211c4419fe
Author: wwp <subscript@free.fr>
Date: Tue, 5 Oct 2021 08:45:35 +0200
Fix CID 1491285: resource leak.
Fix dead code, an another resource leak.
Diffstat:
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/mimeview.c b/src/mimeview.c
@@ -1750,7 +1750,7 @@ static void mimeview_drag_data_get(GtkWidget *widget,
guint time,
MimeView *mimeview)
{
- gchar *filename = NULL, *uriname, *tmp;
+ gchar *filename = NULL, *uriname, *tmp = NULL;
MimeInfo *partinfo;
gint err;
gint count = 0;
@@ -1763,7 +1763,12 @@ static void mimeview_drag_data_get(GtkWidget *widget,
if (strlen(get_part_name(partinfo)) > 0) {
filename = g_path_get_basename(get_part_name(partinfo));
- if (*filename == '\0') return;
+ if (filename) {
+ if (*filename == '\0') {
+ g_free(filename);
+ return;
+ }
+ }
} else if (partinfo->type == MIMETYPE_MESSAGE
&& !g_ascii_strcasecmp(partinfo->subtype, "rfc822")) {
gchar *name = NULL;
@@ -1799,13 +1804,12 @@ static void mimeview_drag_data_get(GtkWidget *widget,
tmp = conv_codeset_strdup(filename,
conv_get_locale_charset_str(),
CS_UTF_8);
- else
- tmp = g_strdup(filename);
if (tmp == NULL) {
g_warning("filename not in UTF-8");
- tmp = g_strdup("Unnamed part");
+ tmp = g_strdup(filename);
}
+ g_free(filename);
filename = g_strconcat(get_mime_tmp_dir(), G_DIR_SEPARATOR_S,
tmp, NULL);