AccountManager: Fix small leak in the account migration code
authorOlivier Goffart <ogoffart@woboq.com>
Wed, 8 Feb 2017 11:30:32 +0000 (12:30 +0100)
committerOlivier Goffart <ogoffart@woboq.com>
Wed, 8 Feb 2017 11:31:07 +0000 (12:31 +0100)
The QSettings object was not deleted in every possible code paths

src/gui/accountmanager.cpp

index fdb77b8f87bb64784248882af2a53667899ff159..9d8b3ed41b06dd4906258240e98af66c3b9a045e 100644 (file)
@@ -86,7 +86,7 @@ bool AccountManager::restoreFromLegacySettings()
 
         QFileInfo fi( oCCfgFile );
         if( fi.isReadable() ) {
-            QSettings *oCSettings = new QSettings(oCCfgFile, QSettings::IniFormat);
+            std::unique_ptr<QSettings> oCSettings(new QSettings(oCCfgFile, QSettings::IniFormat));
             oCSettings->beginGroup(QLatin1String("ownCloud"));
 
             // Check the theme url to see if it is the same url that the oC config was for
@@ -101,9 +101,7 @@ bool AccountManager::restoreFromLegacySettings()
                 qDebug() << "Migrate oC config if " << oCUrl << " == " << overrideUrl << ":"
                          << (oCUrl == overrideUrl ? "Yes" : "No");
                 if( oCUrl == overrideUrl ) {
-                    settings.reset( oCSettings );
-                } else {
-                    delete oCSettings;
+                    settings = std::move(oCSettings);
                 }
             }
         }