File Fix-crash-when-KWallet-is-not-available.patch of Package falkon

From 1cecd14fd069ff778224fe778b7117cb4e3bc0ee Mon Sep 17 00:00:00 2001
From: Puneeth Chanda <puneethchanda2001@gmail.com>
Date: Fri, 24 Jan 2020 14:10:03 +0100
Subject: Fix crash when KWallet is not available.

Summary:
Bug 398767
Currently, when the user clicks //remember password// when KWallet is disabled, **falkon** gets crashed.
This patch fixes the crash by checking if `KWallet` object is created and only then it adds to the folder.
The following functions are fixed:

  - addEntry

  - Update Entry

  - updateLastUsed

  - removeEntry

  - removeAll

Reviewers: SGOrava, drosca

Reviewed By: SGOrava, drosca

Subscribers: drosca, falkon

Tags: #falkon

Differential Revision: https://phabricator.kde.org/D26872
---
 .../kwalletpasswordbackend.cpp                       | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/plugins/KDEFrameworksIntegration/kwalletpasswordbackend.cpp b/src/plugins/KDEFrameworksIntegration/kwalletpasswordbackend.cpp
index c9d0cb3..6b430af 100644
--- a/src/plugins/KDEFrameworksIntegration/kwalletpasswordbackend.cpp
+++ b/src/plugins/KDEFrameworksIntegration/kwalletpasswordbackend.cpp
@@ -82,6 +82,10 @@ void KWalletPasswordBackend::addEntry(const PasswordEntry &entry)
 {
     initialize();
 
+    if (!m_wallet) {
+        return;
+    }
+
     PasswordEntry stored = entry;
     stored.id = QString("%1/%2").arg(entry.host, entry.username);
     stored.updated = QDateTime::currentDateTime().toTime_t();
@@ -94,6 +98,10 @@ bool KWalletPasswordBackend::updateEntry(const PasswordEntry &entry)
 {
     initialize();
 
+    if (!m_wallet) {
+        return false;
+    }
+
     m_wallet->removeEntry(entry.id.toString());
     m_wallet->writeEntry(entry.id.toString(), encodeEntry(entry));
 
@@ -110,6 +118,10 @@ void KWalletPasswordBackend::updateLastUsed(PasswordEntry &entry)
 {
     initialize();
 
+    if (!m_wallet) {
+        return;        
+    }
+
     m_wallet->removeEntry(entry.id.toString());
 
     entry.updated = QDateTime::currentDateTime().toTime_t();
@@ -127,6 +139,10 @@ void KWalletPasswordBackend::removeEntry(const PasswordEntry &entry)
 {
     initialize();
 
+    if (!m_wallet) {
+        return; 
+    }
+
     m_wallet->removeEntry(entry.id.toString());
 
     int index = m_allEntries.indexOf(entry);
@@ -140,6 +156,10 @@ void KWalletPasswordBackend::removeAll()
 {
     initialize();
 
+    if (!m_wallet) {
+        return; 
+    }
+
     m_allEntries.clear();
 
     m_wallet->removeFolder("Falkon");
-- 
cgit v1.1

openSUSE Build Service is sponsored by