[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kfm-devel
Subject:    KDE 1.1.2/PATCH kfm memory leaks/buffer overruns/etc.
From:       Waldo Bastian <bastian () suse ! de>
Date:       1999-09-01 9:13:04
[Download RAW message or body]

Hiya,

The following four patches fix small problms detected with insure:

Patch 1 fixes a memory leak in the htmlcache. If a file does not exist any more,
the QString with its new is never deleted.

Patch 2 fixes a memory leak in KDELnkMimeType. When the comment is requested
the config object is not deleted afterwards.

Patch 3 fixes a delete problem. An array is allocated but it isn't free'ed as an array.

Patch 4 fixes a buffer overrun in the mime-magi detection.

Please test and let me know if I can commit it.

Cheers,
Waldo
["kdebase.kfm.01-09-99.diff1" (text/x-c++)]

Index: htmlcache.cpp
===================================================================
RCS file: /home/kde/kdebase/kfm/Attic/htmlcache.cpp,v
retrieving revision 1.20.4.2
diff -u -r1.20.4.2 htmlcache.cpp
--- htmlcache.cpp	1999/03/24 17:59:01	1.20.4.2
+++ htmlcache.cpp	1999/09/01 09:04:46
@@ -154,6 +154,10 @@
         //debug("HTMLCACHE::slotJobFinished : inserting %s",s->data());
         urlDict->replace( _job->getSrcURL(), s );
     }
+    else 
+    {
+       delete s;
+    }
 
     // Tell all instances
     HTMLCache *p;
@@ -334,7 +338,11 @@
 	  if ( lstat( s->data(), &buff ) == 0 ) {
             //debug("HTMLCACHE : inserting %s",s->data());
 	    urlDict->replace( url, s );
-          } //else debug("HTMLCACHE : _not_ inserting %s",s->data());
+          } 
+          else 
+          {
+            delete s;
+          }
 	}
       }
     } while ( p );

["kdebase.kfm.01-09-99.diff2" (text/x-c++)]

Index: kbind.cpp
===================================================================
RCS file: /home/kde/kdebase/kfm/Attic/kbind.cpp,v
retrieving revision 1.101.2.6
diff -u -r1.101.2.6 kbind.cpp
--- kbind.cpp	1999/07/29 07:28:29	1.101.2.6
+++ kbind.cpp	1999/09/01 09:05:00
@@ -973,12 +973,13 @@
 
 QString KDELnkMimeType::getComment( const char *_url )
 {
-  KSimpleConfig *config = KMimeBind::openKConfig( _url ); // kalle
+    KSimpleConfig *config = KMimeBind::openKConfig( _url ); // kalle
     
     if ( config == 0L )
 	return QString();
     
     QString erg = config->readEntry( "Comment" );
+    delete config;
     return QString( erg.data() );
 }
 

["kdebase.kfm.01-09-99.diff3" (text/x-c++)]

Index: kfmman.cpp
===================================================================
RCS file: /home/kde/kdebase/kfm/Attic/kfmman.cpp,v
retrieving revision 1.107.2.11
diff -u -r1.107.2.11 kfmman.cpp
--- kfmman.cpp	1999/08/28 07:00:01	1.107.2.11
+++ kfmman.cpp	1999/09/01 09:05:08
@@ -1207,7 +1207,7 @@
 	    KMimeType *typ = KMimeType::findByName( aType );
 	    // Have we registered this mime type in KDE ?
 	    if ( typ && typ->run( tryURL ) ){
-	        delete typestr;
+	        if (typestr) delete [] typestr;
 		return;
              }		
 	}
@@ -1221,14 +1221,14 @@
 	  if ( bind )
 	  {
 	    bind->runBinding( tryURL );
-	    if (typestr) delete typestr;
+	    if (typestr) delete [] typestr;
 	    return;
 	  }
 
 	  QString pattern = l.getText();
 	  if ( pattern.isEmpty() )
 	  {
-	    if (typestr) delete typestr;
+	    if (typestr) delete [] typestr;
 	    return;
 	  }	
 	  
@@ -1271,7 +1271,7 @@
 	else
 	    bBufferPage = TRUE;
     }
-    if (typestr) delete typestr;
+    if (typestr) delete [] typestr;
 }
 
 

["kdebase.kfm.01-09-99.diff4" (text/x-c)]

Index: kmimemagic.cpp
===================================================================
RCS file: /home/kde/kdebase/kfm/Attic/kmimemagic.cpp,v
retrieving revision 1.9.4.3
diff -u -r1.9.4.3 kmimemagic.cpp
--- kmimemagic.cpp	1999/04/07 16:59:04	1.9.4.3
+++ kmimemagic.cpp	1999/09/01 09:06:12
@@ -1311,7 +1311,7 @@
 	if (nbytes == 0) {
 		resultBuf += MIME_BINARY_ZEROSIZE;
 	} else {
-		buf[nbytes++] = '\0';	/* null-terminate it */
+		buf[nbytes] = '\0';	/* null-terminate it */
 		tryit(buf, nbytes);
 	}
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic