chatview: prevent QVector::at() call on empty object
Invite a person that have just been removed into the contact list
using the historic panel causes a crash by calling QVector::at()
on an empty QVector instance.
This patch checks for the size of the object and get-out of the function
if empty.
Change-Id: I6846c056b3dc564627028858fc457cfa06828cd1
Reviewed-by: Olivier Soldano <olivier.soldano@savoirfairelinux.com>
diff --git a/src/chatview.cpp b/src/chatview.cpp
index 1b56e58..4ab82f0 100644
--- a/src/chatview.cpp
+++ b/src/chatview.cpp
@@ -198,8 +198,11 @@
// get the account associated to the selected cm
auto active = gtk_combo_box_get_active(GTK_COMBO_BOX(priv->combobox_cm));
- if (priv->person)
- priv->cm = priv->person->phoneNumbers().at(active);
+ if (priv->person) {
+ auto& numbers = priv->person->phoneNumbers();
+ if (not numbers.isEmpty())
+ priv->cm = numbers.at(active);
+ }
if (!priv->cm) {
g_warning("invalid contact, cannot send invitation!");