diff --git a/calendaring/event.cpp b/calendaring/event.cpp --- a/calendaring/event.cpp +++ b/calendaring/event.cpp @@ -141,17 +141,22 @@ void Event::delegate(const std::vector< Attendee >& delegators, const std::vector< Attendee >& delegatees) { - //First build a list of attendee references, and insert any missing attendees - std::vector delegateesRef; + //First insert any missing attendees foreach(const Attendee &a, delegatees) { - if (Attendee *attendee = getAttendee(a.contact())) { - delegateesRef.push_back(attendee); - } else { + if (!getAttendee(a.contact())) { d->attendees.push_back(a); - delegateesRef.push_back(&d->attendees.back()); } } + //Build a list of attendee references + //These are pointers into d->attendees, so we MUST NOT modify that vector after this point! + std::vector delegateesRef; + foreach(const Attendee &a, delegatees) { + Attendee *attendee = getAttendee(a.contact()); + Q_ASSERT(attendee); + delegateesRef.push_back(attendee); + } + std::vector delegatorsRef; foreach(const Attendee& a, delegators) { if (Attendee *attendee = getAttendee(a.contact())) { diff --git a/conversion/kcalconversion.cpp b/conversion/kcalconversion.cpp --- a/conversion/kcalconversion.cpp +++ b/conversion/kcalconversion.cpp @@ -316,7 +316,7 @@ if (!a.uri().empty()) { ptr = KCalCore::Attachment::Ptr(new KCalCore::Attachment(fromStdString(a.uri()), fromStdString(a.mimetype()))); } else { - ptr = KCalCore::Attachment::Ptr(new KCalCore::Attachment(QByteArray::fromRawData(a.data().c_str(), a.data().size()), fromStdString(a.mimetype()))); + ptr = KCalCore::Attachment::Ptr(new KCalCore::Attachment(QByteArray(a.data().c_str(), a.data().size()), fromStdString(a.mimetype()))); } if (!a.label().empty()) { ptr->setLabel(fromStdString(a.label()));