summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2026-03-07 15:48:30 +0200
committerDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2026-04-17 23:41:09 +0300
commitc38519da7bd43f9cfe359d6547a2a682bdb08b9a (patch)
tree7bda17a992acf8340f7f9001ed4103cd2eea1eeb
parentfcd74be338b7ed1b4398a76422e07ff3e0630339 (diff)
message: fix some error paths
-rw-r--r--lib/message/mu-message.cc10
-rw-r--r--lib/message/mu-mime-object.cc12
2 files changed, 13 insertions, 9 deletions
diff --git a/lib/message/mu-message.cc b/lib/message/mu-message.cc
index 4659eb8..126e8df 100644
--- a/lib/message/mu-message.cc
+++ b/lib/message/mu-message.cc
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2022-2024 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
+** Copyright (C) 2022-2026 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** This program is free software; you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by the
@@ -659,8 +659,8 @@ doc_add_list_post(Document& doc, const MimeMessage& mime_msg)
/* some mailing lists do not set the reply-to; see pull #1278. So for
* those cases, check the List-Post address and use that instead */
- GMatchInfo* minfo;
- GRegex* rx;
+ GMatchInfo* minfo{};
+ GRegex* rx{};
const auto list_post{mime_msg.header("List-Post")};
if (!list_post)
return;
@@ -676,7 +676,9 @@ doc_add_list_post(Document& doc, const MimeMessage& mime_msg)
g_free(address);
}
- g_match_info_free(minfo);
+ if (minfo)
+ g_match_info_free(minfo);
+
g_regex_unref(rx);
doc.add_extra_contacts(":list-post", contacts);
diff --git a/lib/message/mu-mime-object.cc b/lib/message/mu-mime-object.cc
index c835e1e..9892d72 100644
--- a/lib/message/mu-mime-object.cc
+++ b/lib/message/mu-mime-object.cc
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2022-2025 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
+** Copyright (C) 2022-2026 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** This program is free software; you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by the
@@ -443,6 +443,9 @@ MimeMessage::references() const noexcept
continue;
GMimeReferences *mime_refs{g_mime_references_parse({}, hdr->c_str())};
+ if (!mime_refs)
+ break;
+
refs.reserve(refs.size() + g_mime_references_length(mime_refs));
for (auto i = 0; i != g_mime_references_length(mime_refs); ++i) {
@@ -560,12 +563,11 @@ MimePart::to_file(const std::string& path, bool overwrite) const noexcept
GMIME_DATA_WRAPPER(wrapper.object()),
GMIME_STREAM(stream.object()))};
- if (written < 0) {
+ if (written < 0)
return Err(Error::Code::File, &err,
"failed to write to '{}'", path);
- }
-
- return Ok(static_cast<size_t>(written));
+ else
+ return Ok(static_cast<size_t>(written));
}
void