File 0001-Fix-KAddressBook-crash-when-editing-a-contact-with-n.patch of Package akonadi-contacts

From f11e81cebba7956f0b0aca27420ab66d7da2b602 Mon Sep 17 00:00:00 2001
From: Jonathan Marten <jjm@keelhaul.me.uk>
Date: Thu, 10 Oct 2024 09:23:15 +0100
Subject: [PATCH] Fix KAddressBook crash when editing a contact with
 nonstandard phone type

In this case PhoneComboBoxType::setType() attempts to insert the new
type as the penultimate item in the mTypeList.  However, using an
iterator for insertion appears to cause an assertion within QList.
There is no need to obtain an interator to do the insertion, the index
can be used directly.

Test case: Importing this contact into KAddressBook and attempting to
edit it will trigger the crash.

VERSION:3.0
EMAIL;TYPE=PREF,WORK:foo@bar.com
EMAIL;TYPE=WORK:info@bar.com
FN:Foo Bar
N:Bar;Foo;;Mx.;
TEL;TYPE=CELL,WORK:0000 000 0000
TEL;TYPE=HOME:01000 000000
END:VCARD

BUG: 494242
---
 .../editor/generalinfoeditor/phone/phonecomboboxtype.cpp        | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/akonadi-contacts-widgets/editor/generalinfoeditor/phone/phonecomboboxtype.cpp b/src/akonadi-contacts-widgets/editor/generalinfoeditor/phone/phonecomboboxtype.cpp
index 0ed7d256..5ff9aac0 100644
--- a/src/akonadi-contacts-widgets/editor/generalinfoeditor/phone/phonecomboboxtype.cpp
+++ b/src/akonadi-contacts-widgets/editor/generalinfoeditor/phone/phonecomboboxtype.cpp
@@ -39,7 +39,7 @@ void PhoneComboBoxType::setType(KContacts::PhoneNumber::Type type)
 {
     if (static_cast<int>(type) != 0) {
         if (!mTypeList.contains(type)) {
-            mTypeList.insert(mTypeList.at(mTypeList.count() - 1), type);
+            mTypeList.insert(mTypeList.count() - 1, type);
         }
     }
     mType = type;
-- 
2.47.0

openSUSE Build Service is sponsored by