From: Laurent Montel Date: Sun, 20 Jul 2008 15:31:14 +0000 (+0000) Subject: Fix potential mem leak X-Git-Tag: v4.1.80~42 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=de80715206dd3af349f4c6f4e96c2674ef0ca98b;p=libqmvoc.git Fix potential mem leak svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=835439 --- diff --git a/keduvocdocument/keduvocdocument.cpp b/keduvocdocument/keduvocdocument.cpp index 97a17f8..564a4cd 100644 --- a/keduvocdocument/keduvocdocument.cpp +++ b/keduvocdocument/keduvocdocument.cpp @@ -108,14 +108,10 @@ KEduVocDocument::KEduVocDocumentPrivate::~KEduVocDocumentPrivate() void KEduVocDocument::KEduVocDocumentPrivate::init() { - if ( m_lessonContainer ) { - delete m_lessonContainer; - } + delete m_lessonContainer; m_lessonContainer = new KEduVocLesson(i18nc("The top level lesson which contains all other lessons of the document.", "Document Lesson")); m_lessonContainer->setContainerType(KEduVocLesson::Lesson); - if ( m_wordTypeContainer ) { - delete m_wordTypeContainer; - } + delete m_wordTypeContainer; m_wordTypeContainer = new KEduVocWordType(i18n( "Word types" )); m_tenseDescriptions.clear(); @@ -253,6 +249,7 @@ int KEduVocDocument::open( const KUrl& url ) if ( !f->open( QIODevice::ReadOnly ) ) { kError() << errorMessage; + delete f; return FileCannotRead; } @@ -337,6 +334,7 @@ int KEduVocDocument::open( const KUrl& url ) QString msg = i18n( "Could not open or properly read \"%1\"\n(Error reported: %2)", url.path(), errorMessage ); kError() << msg << i18n( "Error Opening File" ); ///@todo make the readers return int, pass on the error message properly + delete f; return FileReaderFailed; }