Sophie

Sophie

distrib > Mageia > 5 > i586 > media > core-updates-src > by-pkgid > 5c0256c7d518acfb46629b5e68a44699 > files > 6

akonadi-1.13.0-4.1.mga5.src.rpm

From ca59eb345cfef368242929ea33beca4bff837e9d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Vr=C3=A1til?= <dvratil@redhat.com>
Date: Thu, 18 Sep 2014 16:54:26 +0200
Subject: [PATCH 06/40] Don't crash when setmntent returns NULL

setmntent can fail when there's no /etc/mtab file for instance and
passing NULL pointer to getmntent crashes, so we need to return when
this happens.
---
 server/src/utils.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/server/src/utils.cpp b/server/src/utils.cpp
index b04a81209..b51c330c6 100644
--- a/server/src/utils.cpp
+++ b/server/src/utils.cpp
@@ -179,6 +179,9 @@ QString Utils::getDirectoryFileSystem(const QString &directory)
     QString bestMatchFS;
 
     FILE *mtab = setmntent("/etc/mtab", "r");
+    if (!mtab) {
+        return QString();
+    }
     while (mntent *mnt = getmntent(mtab)) {
         if (qstrcmp(mnt->mnt_type, MNTTYPE_IGNORE) == 0) {
             continue;
-- 
2.14.1