[balsa] Do not g_object_unref NULL pointers; use standard string vector ops
- From: Pawel Salek <pawels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa] Do not g_object_unref NULL pointers; use standard string vector ops
- Date: Sat, 26 Dec 2020 17:43:32 +0000 (UTC)
commit 89526fdeec4f705a5726adee9a368eb8d125feba
Author: Pawel Salek <pawsa0 gmail com>
Date: Sat Dec 26 18:22:45 2020 +0100
Do not g_object_unref NULL pointers; use standard string vector ops
Ocassionally, envelope->sender may be NULL. In this case, do not
try blindly copying it and unref'ing a NULL pointer.
Furthermore, use standard null-terminated string vectors to simplify
the code.
libbalsa/filter-file.c | 6 ++----
libbalsa/mailbox_imap.c | 8 +++++---
2 files changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/libbalsa/filter-file.c b/libbalsa/filter-file.c
index 4546b9b00..2a5b83da3 100644
--- a/libbalsa/filter-file.c
+++ b/libbalsa/filter-file.c
@@ -185,7 +185,7 @@ libbalsa_mailbox_filters_save_config(LibBalsaMailbox * mbox)
}
names=g_slist_reverse(names);
/* Second we construct the vector of gchar * */
- filters_names = g_new(gchar *, nb_filters);
+ filters_names = g_new(gchar *, nb_filters + 1);
lst = names;
for(i = 0; i < nb_filters; i++) {
filters_names[i] = (gchar*) lst->data;
@@ -204,9 +204,7 @@ libbalsa_mailbox_filters_save_config(LibBalsaMailbox * mbox)
}
libbalsa_conf_set_vector(MAILBOX_FILTERS_WHEN_KEY,nb_filters,
(const gchar **) filters_names);
- for (i = 0; i < nb_filters; i++)
- g_free(filters_names[i]);
- g_free(filters_names);
+ g_strfreev(filters_names);
}
/* Temporary code for transition from 2.0.x */
diff --git a/libbalsa/mailbox_imap.c b/libbalsa/mailbox_imap.c
index b124646fc..c672b1686 100644
--- a/libbalsa/mailbox_imap.c
+++ b/libbalsa/mailbox_imap.c
@@ -2015,9 +2015,11 @@ libbalsa_mailbox_imap_load_envelope(LibBalsaMailboxImap *mimap,
envelope = imsg->envelope;
libbalsa_message_set_subject_from_header(message, envelope->subject);
- sender = internet_address_new_list_from_imap_address_list(envelope->sender);
- libbalsa_message_set_sender(message, sender);
- g_object_unref(sender);
+ if (envelope->sender) {
+ sender = internet_address_new_list_from_imap_address_list(envelope->sender);
+ libbalsa_message_set_sender(message, sender);
+ g_object_unref(sender);
+ }
libbalsa_message_set_in_reply_to_from_string(message, envelope->in_reply_to);
if (envelope->message_id != NULL) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]