Skip to content

Commit bd3c63f

Browse files
committed
fix wrong dereferencing
1 parent d334e47 commit bd3c63f

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/mimemessage.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,11 @@ void MimeMessage::setSubject(const QString &subject)
192192

193193
void MimeMessage::addPart(const std::shared_ptr<MimePart> &part)
194194
{
195-
auto content = *d->content;
196-
if (typeid(content) == typeid(MimeMultiPart)) {
197-
std::static_pointer_cast<MimeMultiPart>(d->content)->addPart(part);
195+
if (d->content) {
196+
auto& content = *d->content;
197+
if (typeid(content) == typeid(MimeMultiPart)) {
198+
std::static_pointer_cast<MimeMultiPart>(d->content)->addPart(part);
199+
}
198200
}
199201
}
200202

@@ -231,11 +233,13 @@ QString MimeMessage::subject() const
231233
QList<std::shared_ptr<MimePart>> MimeMessage::parts() const
232234
{
233235
QList<std::shared_ptr<MimePart>> ret;
234-
auto content = *d->content;
235-
if (typeid(content) == typeid(MimeMultiPart)) {
236-
ret = std::static_pointer_cast<MimeMultiPart>(d->content)->parts();
237-
} else {
238-
ret.append(std::shared_ptr<MimePart>(d->content));
236+
if (d->content) {
237+
auto& content = *d->content;
238+
if (typeid(content) == typeid(MimeMultiPart)) {
239+
ret = std::static_pointer_cast<MimeMultiPart>(d->content)->parts();
240+
} else {
241+
ret.append(std::shared_ptr<MimePart>(d->content));
242+
}
239243
}
240244

241245
return ret;

0 commit comments

Comments
 (0)