Branch 'libkolab-0.4' - kolabformat/v2helpers.h mime/mimeutils.cpp
Christian Mollekopf
mollekopf at kolabsys.com
Fri Feb 15 20:45:28 CET 2013
kolabformat/v2helpers.h | 5 ++++-
mime/mimeutils.cpp | 8 ++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
New commits:
commit ffa5b196b996b0081eabc6ea9c589b4325012e43
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Fri Feb 15 20:37:01 2013 +0100
Error out early, and avoid assert as this is a realistic error scenario.
diff --git a/kolabformat/v2helpers.h b/kolabformat/v2helpers.h
index 3e2f2f7..f883efb 100644
--- a/kolabformat/v2helpers.h
+++ b/kolabformat/v2helpers.h
@@ -46,7 +46,10 @@ template <typename KCalPtr, typename Container>
static KCalPtr fromXML(const QByteArray &xmlData, QStringList &attachments)
{
const QDomDocument xmlDoc = KolabV2::KolabBase::loadDocument( QString::fromUtf8(xmlData) ); //TODO extract function from V2 format
- Q_ASSERT ( !xmlDoc.isNull() );
+ if ( xmlDoc.isNull() ) {
+ Error() << "Failed to read the xml document";
+ return KCalPtr();
+ }
const KCalPtr i = Container::fromXml( xmlDoc, QString() ); //For parsing we don't need the timezone, so we don't set one
Q_ASSERT ( i );
QDomNodeList nodes = xmlDoc.elementsByTagName("inline-attachment");
diff --git a/mime/mimeutils.cpp b/mime/mimeutils.cpp
index 4f913a8..2ce6475 100644
--- a/mime/mimeutils.cpp
+++ b/mime/mimeutils.cpp
@@ -258,6 +258,10 @@ KMime::Content* createAttachmentPart(const QByteArray& cid, const QString& mimeT
void getAttachments(KCalCore::Incidence::Ptr incidence, const QStringList &attachments, const KMime::Message::Ptr &mimeData)
{
+ if (!incidence) {
+ Error() << "Invalid incidence";
+ return;
+ }
// kDebug() << "getting " << attachments.size() << "attachments";
// kDebug() << mimeData->encodedContent();
foreach (const QString &name, attachments) {
@@ -278,6 +282,10 @@ void getAttachments(KCalCore::Incidence::Ptr incidence, const QStringList &attac
void getAttachmentsById(KCalCore::Incidence::Ptr incidence, const KMime::Message::Ptr &mimeData)
{
+ if (!incidence) {
+ Error() << "Invalid incidence";
+ return;
+ }
// kDebug() << "getting " << attachments.size() << "attachments";
// kDebug() << mimeData->encodedContent();
More information about the commits
mailing list