From cad952f1a207109b77d9edc7f0f1d252fb89f292 Mon Sep 17 00:00:00 2001
From: Emmanuel Lepage Vallee <elv1313@gmail.com>
Date: Fri, 28 Apr 2017 22:48:01 -0400
Subject: [PATCH] peerprofile: Check the result of `open()`
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Change-Id: Ib5af845fbdc039a8986c680ad650ce04aed66bcc
Reviewed-by: Nicolas Jäger <nicolas.jager@savoirfairelinux.com>
---
 src/peerprofilecollection.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/peerprofilecollection.cpp b/src/peerprofilecollection.cpp
index c0065a00..2b74ef78 100644
--- a/src/peerprofilecollection.cpp
+++ b/src/peerprofilecollection.cpp
@@ -74,7 +74,12 @@ bool PeerProfileEditor::save(const Person* pers)
     const auto& result = pers->toVCard();
 
     QFile file {filename};
-    file.open(QIODevice::WriteOnly);
+
+    if (Q_UNLIKELY(!file.open(QIODevice::WriteOnly))) {
+        qWarning() << "Can't write to" << filename;
+        return false;
+    }
+
     file.write(result);
     file.close();
     return true;
-- 
GitLab