From c7695063605829ccfe0e8bdeb0137bf1d64cdbf5 Mon Sep 17 00:00:00 2001 From: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com> Date: Thu, 25 May 2017 13:54:46 -0400 Subject: [PATCH] media/text: fix invalid reference MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit VCardUtils::parseMimeAttributes() returns by value, but it was used in IMConversationManagerPrivate::newMessage() by reference. So this reference is on a stack-allocated object and can be invalidated by the system. Use a by-value copy, mostly optimized by compiler with copy elision [1]. [1] http://en.cppreference.com/w/cpp/language/copy_elision Change-Id: I1b7ef8eb1ebc738949243d5ace1363d4b4fa3caf Reviewed-by: Nicolas Jäger <nicolas.jager@savoirfairelinux.com> --- src/media/text.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/media/text.cpp b/src/media/text.cpp index 57d94077..a6453de4 100644 --- a/src/media/text.cpp +++ b/src/media/text.cpp @@ -155,7 +155,7 @@ void IMConversationManagerPrivate::newMessage(const QString& callId, const QStri iter.next(); if (iter.key().left(profileSize) == RingMimes::PROFILE_VCF) { - const auto& args = VCardUtils::parseMimeAttributes(iter.key()); + auto args = VCardUtils::parseMimeAttributes(iter.key()); if (auto person = ProfileChunk::addChunk(args, iter.value(), call->peerContactMethod())) { PersonModel::instance().addPeerProfile(person); } -- GitLab