Crash fix for KParts::PartManager

Andreas Pakulat apaku at gmx.de
Mon Feb 19 00:25:50 GMT 2007


Hi,

just found that KPart::PartManager::addPart happily crashes when handed
a 0-pointer. While one could argue that this shouldn't happen in the
first place its also not nice to just crash in this case. The patch
below adds a check and a kfatal output. 

If nobody objects I'll commit that on tuesday.

Andreas

-- 
You will be surrounded by luxury.
-------------- next part --------------
Index: kparts/partmanager.cpp
===================================================================
--- kparts/partmanager.cpp	(Revision 634794)
+++ kparts/partmanager.cpp	(Arbeitskopie)
@@ -328,6 +328,11 @@ Part * PartManager::findPartFromWidget( 
 
 void PartManager::addPart( Part *part, bool setActive )
 {
+    if( !part )
+    {
+        kFatal(1000) << k_funcinfo << QString("Can't add part, its a 0-pointer.") << endl;
+        return;
+    }
     // don't add parts more than once :)
     if ( d->m_parts.contains( part ) ) {
     #ifdef DEBUG_PARTMANAGER


More information about the kde-core-devel mailing list