diff --git a/src/mimemessage.cpp b/src/mimemessage.cpp index 2aafdea..c955cd0 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(d->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(d->content)->parts(); + } else { + ret.append(std::shared_ptr(d->content)); + } } return ret;