summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Rosenberger <johannes.rosenberger@jorsn.eu>2019-08-11 13:05:58 +0200
committerJohannes Rosenberger <johannes.rosenberger@jorsn.eu>2019-08-11 13:29:55 +0200
commit1a3eee87b2c4c3a27bc9af405e43c706e950414c (patch)
tree783bc02e24b0cc67f84f3faa1e0bf4d620d7d059
parent47548b087df6befe2308fa21ada03e42d36f5971 (diff)
ComposeMessage::build() ensure initialization of stream
code safety: fixes compiler warning -Wmaybe-uninitialized
-rw-r--r--src/compose_message.cc14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/compose_message.cc b/src/compose_message.cc
index 23cc6a9..4202d95 100644
--- a/src/compose_message.cc
+++ b/src/compose_message.cc
@@ -176,7 +176,7 @@ namespace Astroid {
g_mime_object_set_content_type_parameter ((GMimeObject *) html, "format", "flowed");
}
- GMimeStream * contentStream;
+ GMimeStream * contentStream = g_mime_stream_mem_new();
/* pipe through markdown to html generator */
int pid;
@@ -224,7 +224,11 @@ namespace Astroid {
LOG (debug) << "cm: md: got html: " << _html;
- contentStream = g_mime_stream_mem_new_with_buffer(_html.c_str(), _html.bytes());
+ if (0 > g_mime_stream_write(contentStream, _html.c_str(), _html.bytes())) {
+ LOG (error) << "cm: md: could not write html string to GMimeStream contentStream";
+ markdown_error = "Could not write html string to GMimeStream contentStream";
+ markdown_success = false;
+ }
}
g_spawn_close_pid (pid);
@@ -242,15 +246,15 @@ namespace Astroid {
g_mime_part_set_content_encoding (html, GMIME_CONTENT_ENCODING_QUOTEDPRINTABLE);
g_mime_part_set_content (html, contentWrapper);
- g_object_unref(contentWrapper);
- g_object_unref(contentStream);
-
/* add html part to message */
g_mime_multipart_add (multipartAlt, GMIME_OBJECT (html));
messagePart = GMIME_OBJECT(multipartAlt);
+
+ g_object_unref(contentWrapper);
g_object_unref (text);
}
+ g_object_unref(contentStream);
g_object_unref (html);
}