Skip to content

Commit

Permalink
fix wrong dereferencing
Browse files Browse the repository at this point in the history
  • Loading branch information
640kb committed Jul 11, 2024
1 parent d334e47 commit fd27d1a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/mimemessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,10 @@ void MimeMessage::setSubject(const QString &subject)

void MimeMessage::addPart(const std::shared_ptr<MimePart> &part)
{
auto content = *d->content;
if (typeid(content) == typeid(MimeMultiPart)) {
std::static_pointer_cast<MimeMultiPart>(d->content)->addPart(part);
if (d->content) {
if (typeid(*(d->content)) == typeid(MimeMultiPart)) {
std::static_pointer_cast<MimeMultiPart>(d->content)->addPart(part);
}
}
}

Expand Down Expand Up @@ -231,11 +232,12 @@ QString MimeMessage::subject() const
QList<std::shared_ptr<MimePart>> MimeMessage::parts() const
{
QList<std::shared_ptr<MimePart>> ret;
auto content = *d->content;
if (typeid(content) == typeid(MimeMultiPart)) {
ret = std::static_pointer_cast<MimeMultiPart>(d->content)->parts();
} else {
ret.append(std::shared_ptr<MimePart>(d->content));
if (d->content) {
if (typeid(*(d->content)) == typeid(MimeMultiPart)) {
ret = std::static_pointer_cast<MimeMultiPart>(d->content)->parts();
} else {
ret.append(std::shared_ptr<MimePart>(d->content));
}
}

return ret;
Expand Down

0 comments on commit fd27d1a

Please sign in to comment.