From d41828930042a7e38fa808ed4c97234f5ad71965 Mon Sep 17 00:00:00 2001 From: Daniel Wendt Date: Thu, 11 Jul 2024 08:57:52 +0200 Subject: [PATCH] fix wrong dereferencing --- src/mimemessage.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/mimemessage.cpp b/src/mimemessage.cpp index 2aafdea..b9ab166 100644 --- a/src/mimemessage.cpp +++ b/src/mimemessage.cpp @@ -192,9 +192,11 @@ void MimeMessage::setSubject(const QString &subject) void MimeMessage::addPart(const std::shared_ptr &part) { - auto content = *d->content; - if (typeid(content) == typeid(MimeMultiPart)) { - std::static_pointer_cast(d->content)->addPart(part); + if (d->content) { + auto content = d->content; + if (typeid(*content) == typeid(MimeMultiPart)) { + std::static_pointer_cast(content)->addPart(part); + } } } @@ -231,11 +233,13 @@ QString MimeMessage::subject() const QList> MimeMessage::parts() const { QList> ret; - auto content = *d->content; - if (typeid(content) == typeid(MimeMultiPart)) { - ret = std::static_pointer_cast(d->content)->parts(); - } else { - ret.append(std::shared_ptr(d->content)); + if (d->content) { + auto content = d->content; + if (typeid(*content) == typeid(MimeMultiPart)) { + ret = std::static_pointer_cast(content)->parts(); + } else { + ret.append(std::shared_ptr(content)); + } } return ret;