[balsa/wip/gmime3: 18/197] Handle GError pointer more carefully
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/wip/gmime3: 18/197] Handle GError pointer more carefully
- Date: Wed, 23 May 2018 21:13:52 +0000 (UTC)
commit 82d17184ef934dad8bb248b7c52e2f1fadeebd8d
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Wed Jun 28 17:36:42 2017 -0400
Handle GError pointer more carefully
* libbalsa/body.c
(libbalsa_message_body_set_text_rfc822headers): do not create a
GError and then ignore it;
(libbalsa_message_body_get_stream): allow NULL GError pointer,
and take more care in setting errors when it is non-NULL.
ChangeLog | 10 ++++++++++
libbalsa/body.c | 30 +++++++++++++++++++-----------
2 files changed, 29 insertions(+), 11 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a7b283a..371e5fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2017-06-28 Peter Bloomfield <pbloomfield bellsouth net>
+ Handle GError pointer more carefully
+
+ * libbalsa/body.c
+ (libbalsa_message_body_set_text_rfc822headers): do not create a
+ GError and then ignore it;
+ (libbalsa_message_body_get_stream): allow NULL GError pointer,
+ and take more care in setting errors when it is non-NULL.
+
+2017-06-28 Peter Bloomfield <pbloomfield bellsouth net>
+
Assert that a node is not NULL
* libbalsa/mailbox.c (lbm_next): assert that node is not NULL
diff --git a/libbalsa/body.c b/libbalsa/body.c
index 5e8cfc5..609fcd6 100644
--- a/libbalsa/body.c
+++ b/libbalsa/body.c
@@ -220,13 +220,9 @@ static void
libbalsa_message_body_set_text_rfc822headers(LibBalsaMessageBody *body)
{
GMimeStream *headers;
- GError *err = NULL;
libbalsa_mailbox_lock_store(body->message->mailbox);
- headers = libbalsa_message_body_get_stream(body, &err);
- if (err != NULL) {
- g_error_free(err);
- }
+ headers = libbalsa_message_body_get_stream(body, NULL);
if (headers != NULL) {
GMimeMessage *dummy_msg;
@@ -587,21 +583,33 @@ libbalsa_message_body_get_stream(LibBalsaMessageBody * body, GError **err)
g_return_val_if_fail(body->message != NULL, NULL);
if (!body->message->mailbox) {
- g_set_error(err, LIBBALSA_MAILBOX_ERROR,
- LIBBALSA_MAILBOX_ACCESS_ERROR,
- "Internal error in get_stream");
+ if (err != NULL && *err == NULL) {
+ g_set_error(err, LIBBALSA_MAILBOX_ERROR,
+ LIBBALSA_MAILBOX_ACCESS_ERROR,
+ "Internal error in get_stream");
+ }
return NULL;
}
if (!libbalsa_mailbox_get_message_part(body->message, body, err)
- || !(GMIME_IS_PART(body->mime_part)
- || GMIME_IS_MESSAGE_PART(body->mime_part))) {
- if (err && !*err)
+ || body->mime_part == NULL) {
+ if (err != NULL && *err == NULL) {
+ g_set_error(err, LIBBALSA_MAILBOX_ERROR,
+ LIBBALSA_MAILBOX_ACCESS_ERROR,
+ "Cannot get stream for part");
+ }
+ return NULL;
+ }
+
+ if (!(GMIME_IS_PART(body->mime_part)
+ || GMIME_IS_MESSAGE_PART(body->mime_part))) {
+ if (err != NULL && *err == NULL) {
g_set_error(err, LIBBALSA_MAILBOX_ERROR,
LIBBALSA_MAILBOX_ACCESS_ERROR,
"Cannot get stream for part of type %s",
g_type_name(G_TYPE_FROM_INSTANCE
(body->mime_part)));
+ }
return NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]