diff options
| author | Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> | 2023-07-05 20:21:42 +0300 |
|---|---|---|
| committer | Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> | 2023-07-06 07:41:40 +0300 |
| commit | 1494df4a48c05085a65429ccc9cebb947ea51950 (patch) | |
| tree | dd4aa42efbff62c917e0273b9feb6060ca3fc7b1 | |
| parent | 11d47e0eab9d62eb87ca1d9d8c65c52cc99a576e (diff) | |
message: double-check part-type in Multipart
Avoid exception for some messages (unsigned messages with signed
attachment).
| -rw-r--r-- | lib/message/mu-mime-object.hh | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/message/mu-mime-object.hh b/lib/message/mu-mime-object.hh index af0e23f..d89c4b4 100644 --- a/lib/message/mu-mime-object.hh +++ b/lib/message/mu-mime-object.hh @@ -1291,12 +1291,15 @@ public: void for_each(const ForEachFunc& func) const noexcept; private: - + // Note: the part may not be available if the message was marked as + // _signed_ or _encrypted_ because it contained a forwarded signed or + // encrypted message. Option<MimePart> part(int index) const { - if (MimeObject mobj{g_mime_multipart_get_part(self(),index)}; !mobj) + if (auto&& p{g_mime_multipart_get_part(self() ,index)}; + !GMIME_IS_PART(p)) return Nothing; else - return mobj; + return Some(MimeObject{p}); } GMimeMultipart* self() const { |
