From cc98710df73a590c37dca19bd3aa9fcd9bbd5a92 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 15 Aug 2011 18:10:02 +0200 Subject: don't crash when destroying codec list this was uncovered by rittk's don't-detach patch. --- src/corelib/codecs/qtextcodec.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/corelib/codecs') diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index 0a37f27f23..263b5f9921 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -213,12 +213,13 @@ QTextCodecCleanup::~QTextCodecCleanup() destroying_is_ok = true; #endif - for (QList::const_iterator it = all->constBegin() - ; it != all->constEnd(); ++it) { + QList *myAll = all; + all = 0; // Otherwise the d'tor destroys the iterator + for (QList::const_iterator it = myAll->constBegin() + ; it != myAll->constEnd(); ++it) { delete *it; } - delete all; - all = 0; + delete myAll; localeMapper = 0; #ifdef Q_DEBUG_TEXTCODEC -- cgit v1.2.3