Skip to content
Snippets Groups Projects
Commit 6c46d35a authored by Olivier SOLDANO's avatar Olivier SOLDANO Committed by Guillaume Roguez
Browse files

Fix null pointer access in decorationRole


The validity on the contact method pointer was not checked
in the decorationRole getter in pixbufmanipulator,
hence sometimes leading to segfault.

Change-Id: I3b43381285511cae58f94d8023ca6ed3b76e85c7
Reviewed-by: default avatarGuillaume Roguez <guillaume.roguez@savoirfairelinux.com>
parent 6c318897
No related branches found
No related tags found
No related merge requests found
...@@ -194,10 +194,16 @@ QVariant PixbufManipulator::decorationRole(const ContactMethod* cm) ...@@ -194,10 +194,16 @@ QVariant PixbufManipulator::decorationRole(const ContactMethod* cm)
QImage photo; QImage photo;
if (cm && cm->contact() && cm->contact()->photo().isValid()) if (cm && cm->contact() && cm->contact()->photo().isValid())
photo = cm->contact()->photo().value<QImage>(); photo = cm->contact()->photo().value<QImage>();
else else if (cm){
photo = fallbackAvatar(imgSize_, photo = fallbackAvatar(imgSize_,
cm->uri().userinfo().at(0).toLatin1(), cm->uri().userinfo().at(0).toLatin1(),
cm->bestName().at(0).toUpper().toLatin1()); cm->bestName().at(0).toUpper().toLatin1());
} else {
photo = fallbackAvatar(imgSize_,
QString("?").at(0).toLatin1(),
QString("?").at(0).toUpper().toLatin1());
}
return QVariant::fromValue(scaleAndFrame(photo, imgSize_)); return QVariant::fromValue(scaleAndFrame(photo, imgSize_));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment