diff options
author | Laurent Montel <montel@kde.org> | 2003-11-22 14:21:13 +0000 |
---|---|---|
committer | Aleix Pol <aleixpol@kde.org> | 2014-04-26 14:11:12 +0200 |
commit | 944bd7a33407074176fda83e6b50fafd63341d34 (patch) | |
tree | 4a65f3be3ada313037f84a90d55f4e9c0a59b10d | |
parent | 5d614e20b4401e91e879b35107c0a473c735ab48 (diff) | |
download | kconfig-944bd7a33407074176fda83e6b50fafd63341d34.tar.gz kconfig-944bd7a33407074176fda83e6b50fafd63341d34.tar.bz2 |
Fix mem leak (delete config before close application)
svn path=/trunk/kdebase/src/kreadconfig/; revision=268830
-rw-r--r-- | src/kreadconfig/kreadconfig.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/kreadconfig/kreadconfig.cpp b/src/kreadconfig/kreadconfig.cpp index c1a6d069..dcd5ed18 100644 --- a/src/kreadconfig/kreadconfig.cpp +++ b/src/kreadconfig/kreadconfig.cpp @@ -67,21 +67,32 @@ int main(int argc, char **argv) KInstance inst(&aboutData); KConfig *konfig; + bool configMustDeleted = false; if (file.isEmpty()) konfig = KGlobal::config(); else + { konfig = new KConfig(file, true, false); - + configMustDeleted=true; + } konfig->setGroup(group); if(type=="bool") { dflt=dflt.lower(); bool def=(dflt=="true" || dflt=="on" || dflt=="yes" || dflt=="1"); - return !konfig->readBoolEntry(key, def); + bool retValue = !konfig->readBoolEntry(key, def); + if ( configMustDeleted ) + delete konfig; + return retValue; } else if(type=="num") { - return konfig->readLongNumEntry(key, dflt.toLong()); + long retValue = konfig->readLongNumEntry(key, dflt.toLong()); + if ( configMustDeleted ) + delete konfig; + return retValue; } else { - /* Assume it's a string... */ + /* Assume it's a string... */ fprintf(stdout, "%s\n", konfig->readEntry(key, dflt).local8Bit().data()); + if ( configMustDeleted ) + delete konfig; return 0; } } |