message: fix some error paths

This commit is contained in:
Dirk-Jan C. Binnema
2026-03-07 15:48:30 +02:00
committed by Seth Ladygo
parent d8d02b6d6a
commit 5e9cdc6654
2 changed files with 13 additions and 9 deletions

View File

@ -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 ** 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 ** 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 /* 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 */ * those cases, check the List-Post address and use that instead */
GMatchInfo* minfo; GMatchInfo* minfo{};
GRegex* rx; GRegex* rx{};
const auto list_post{mime_msg.header("List-Post")}; const auto list_post{mime_msg.header("List-Post")};
if (!list_post) if (!list_post)
return; return;
@ -676,7 +676,9 @@ doc_add_list_post(Document& doc, const MimeMessage& mime_msg)
g_free(address); g_free(address);
} }
g_match_info_free(minfo); if (minfo)
g_match_info_free(minfo);
g_regex_unref(rx); g_regex_unref(rx);
doc.add_extra_contacts(":list-post", contacts); doc.add_extra_contacts(":list-post", contacts);

View File

@ -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 ** 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 ** under the terms of the GNU General Public License as published by the
@ -443,6 +443,9 @@ MimeMessage::references() const noexcept
continue; continue;
GMimeReferences *mime_refs{g_mime_references_parse({}, hdr->c_str())}; GMimeReferences *mime_refs{g_mime_references_parse({}, hdr->c_str())};
if (!mime_refs)
break;
refs.reserve(refs.size() + g_mime_references_length(mime_refs)); refs.reserve(refs.size() + g_mime_references_length(mime_refs));
for (auto i = 0; i != g_mime_references_length(mime_refs); ++i) { 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_DATA_WRAPPER(wrapper.object()),
GMIME_STREAM(stream.object()))}; GMIME_STREAM(stream.object()))};
if (written < 0) { if (written < 0)
return Err(Error::Code::File, &err, return Err(Error::Code::File, &err,
"failed to write to '{}'", path); "failed to write to '{}'", path);
} else
return Ok(static_cast<size_t>(written));
return Ok(static_cast<size_t>(written));
} }
void void