[balsa] send: Plug memory leak in error return paths
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa] send: Plug memory leak in error return paths
- Date: Mon, 18 Feb 2019 23:36:19 +0000 (UTC)
commit 73c8ac6a74fae127efd333512ac5b1870ba73b8f
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Mon Feb 18 18:12:45 2019 -0500
send: Plug memory leak in error return paths
* libbalsa/send.c (libbalsa_message_create_mime_message): do not
leak mime_type in error return paths; also reduce scope of
mime_type.
ChangeLog | 6 ++++++
libbalsa/send.c | 8 +++++---
2 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0ff0689cb..5f1246cf0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2019-02-18 Peter Bloomfield <pbloomfield bellsouth net>
+
+ * libbalsa/send.c (libbalsa_message_create_mime_message): do not
+ leak mime_type in error return paths; also reduce scope of
+ mime_type.
+
2019-02-18 Peter Bloomfield <pbloomfield bellsouth net>
* libbalsa/address.c (vcard_strsplit): eliminate one decrement,
diff --git a/libbalsa/send.c b/libbalsa/send.c
index 38947d2af..51908f578 100644
--- a/libbalsa/send.c
+++ b/libbalsa/send.c
@@ -1202,7 +1202,6 @@ libbalsa_message_create_mime_message(LibBalsaMessage *message,
gboolean postponing,
GError **error)
{
- gchar **mime_type;
GMimeObject *mime_root = NULL;
GMimeMessage *mime_message;
LibBalsaMessageBody *body;
@@ -1231,12 +1230,13 @@ libbalsa_message_create_mime_message(LibBalsaMessage *message,
mime_part = NULL;
if ((body->file_uri != NULL) || (body->filename != NULL)) {
+ gchar **mime_type;
+
if (body->content_type != NULL) {
mime_type = parse_content_type(body->content_type);
} else {
- gchar *mt = g_strdup(libbalsa_vfs_get_mime_type(body->file_uri));
+ const gchar *mt = libbalsa_vfs_get_mime_type(body->file_uri);
mime_type = g_strsplit(mt, "/", 2);
- g_free(mt);
}
if (body->attach_mode == LIBBALSA_ATTACH_AS_EXTBODY) {
@@ -1281,6 +1281,7 @@ libbalsa_message_create_mime_message(LibBalsaMessage *message,
g_clear_error(&err);
g_free(msg);
}
+ g_strfreev(mime_type);
return LIBBALSA_MESSAGE_CREATE_ERROR;
}
parser = g_mime_parser_new_with_stream(stream);
@@ -1348,6 +1349,7 @@ libbalsa_message_create_mime_message(LibBalsaMessage *message,
g_free(msg);
}
g_object_unref(G_OBJECT(mime_part));
+ g_strfreev(mime_type);
return LIBBALSA_MESSAGE_CREATE_ERROR;
}
content = g_mime_data_wrapper_new_with_stream(stream,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]