summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Faure <faure@kde.org>2017-08-01 12:01:58 +0200
committerDavid Faure <faure@kde.org>2017-08-15 21:27:30 +0200
commit73a0ca3642cd3bf298b6556561759bc20e44495d (patch)
treeae3053e37f0ba4f0cbf4934a68bc034ff73533f0
parent25148bd72686b6fa1af46caa67d46a6383ffe5b3 (diff)
downloadlibkolab-libkolab-1.0.tar.gz
Fix crashes when the XML parsing fails.libkolab-1.0
Summary: This code was dereferencing a null pointer, leading to a repeatable crash of the kolab resource when parsing an invalid event. Reviewers: mollekopf, knauss, knauss2 Reviewed By: mollekopf Differential Revision: https://git.kolab.org/D503
-rw-r--r--kolabformat/mimeobject.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/kolabformat/mimeobject.cpp b/kolabformat/mimeobject.cpp
index 3b88432..b162419 100644
--- a/kolabformat/mimeobject.cpp
+++ b/kolabformat/mimeobject.cpp
@@ -254,25 +254,31 @@ QVariant MIMEObject::Private::readKolabV2(const KMime::Message::Ptr &msg, Kolab:
case EventObject: {
QStringList attachments;
KCalCore::Event::Ptr kEvent = fromXML<KCalCore::Event::Ptr, KolabV2::Event>(xmlData, attachments);
- Kolab::Event event = Kolab::Conversion::fromKCalCore(*kEvent);
- event.setAttachments(getAttachments(attachments, msg));
- variant = QVariant::fromValue(event);
+ if (kEvent) {
+ Kolab::Event event = Kolab::Conversion::fromKCalCore(*kEvent);
+ event.setAttachments(getAttachments(attachments, msg));
+ variant = QVariant::fromValue(event);
+ }
break;
}
case TodoObject: {
QStringList attachments;
KCalCore::Todo::Ptr kTodo = fromXML<KCalCore::Todo::Ptr, KolabV2::Task>(xmlData, attachments);
- Kolab::Todo todo = Kolab::Conversion::fromKCalCore(*kTodo);
- todo.setAttachments(getAttachments(attachments, msg));
- variant = QVariant::fromValue(todo);
+ if (kTodo) {
+ Kolab::Todo todo = Kolab::Conversion::fromKCalCore(*kTodo);
+ todo.setAttachments(getAttachments(attachments, msg));
+ variant = QVariant::fromValue(todo);
+ }
break;
}
case JournalObject: {
QStringList attachments;
KCalCore::Journal::Ptr kJournal = fromXML<KCalCore::Journal::Ptr, KolabV2::Journal>(xmlData, attachments);
- Kolab::Journal journal = Kolab::Conversion::fromKCalCore(*kJournal);
- journal.setAttachments(getAttachments(attachments, msg));
- variant = QVariant::fromValue(journal);
+ if (kJournal) {
+ Kolab::Journal journal = Kolab::Conversion::fromKCalCore(*kJournal);
+ journal.setAttachments(getAttachments(attachments, msg));
+ variant = QVariant::fromValue(journal);
+ }
break;
}
case ContactObject: {