Fix even more leaks
authorCloudef <mailRoxas@gmail.com>
Wed, 31 Aug 2011 14:53:22 +0000 (17:53 +0300)
committerskeezix <skeezix@fw.skeleton.org>
Fri, 2 Sep 2011 13:20:20 +0000 (09:20 -0400)
lib/pnd_conf.c
lib/pnd_locate.c
lib/pnd_pxml.c
lib/pnd_tinyxml.cpp

index 9c4f31f..824fbb3 100644 (file)
@@ -79,6 +79,7 @@ pnd_conf_handle pnd_conf_fetch_by_name ( char *filename, char *searchpath ) {
     conf = pnd_conf_fetch_by_path ( buffer );
 
     if ( conf ) {
+      wordfree ( &_p );
       return ( conf );
     }
 
index 6e4afbb..1beb76c 100644 (file)
@@ -25,6 +25,7 @@ char *pnd_locate_filename ( char *searchpath, char *filename ) {
 
     if ( stat ( buffer, &foo ) == 0 ) {
       strcpy ( pnd_locate_buffer, buffer );
+      wordfree( &_p );
       return ( pnd_locate_buffer );
     }
 
index 29e996d..77fc011 100644 (file)
@@ -16,6 +16,7 @@ pnd_pxml_handle *pnd_pxml_fetch ( char *fullpath ) {
   FILE *f;
   char *b;
   unsigned int len;
+  pnd_pxml_handle *h;
 
   f = fopen ( fullpath, "r" );
 
@@ -44,7 +45,10 @@ pnd_pxml_handle *pnd_pxml_fetch ( char *fullpath ) {
 
   fclose ( f );
 
-  return ( pnd_pxml_fetch_buffer ( fullpath, b ) );
+  h = pnd_pxml_fetch_buffer ( fullpath, b );
+  free ( b );
+
+  return ( h );
 }
 
 pnd_pxml_handle *pnd_pxml_fetch_buffer ( char *filename, char *buffer ) {
@@ -204,6 +208,9 @@ void pnd_pxml_delete ( pnd_pxml_handle h ) {
   if ( p -> execargs ) {
     free ( p -> execargs );
   }
+  if ( p -> mkdir_sp ) {
+    free ( p -> mkdir_sp );
+  }
   if ( p -> package_version_major ) {
     free ( p -> package_version_major );
   }
index 577aef0..1aa8f9b 100644 (file)
@@ -423,7 +423,13 @@ unsigned char pnd_pxml_parse ( const char *pFilename, char *buffer, unsigned int
        char *filetype = pnd_pxml_get_attribute(pElem, PND_PXML_ATTRNAME_ASSOCFTYPE);
        char *paramter = pnd_pxml_get_attribute(pElem, PND_PXML_ATTRNAME_ASSOCARGS);
 
-       if (!(name && filetype && paramter)) continue;
+       if (!(name && filetype && paramter))
+       {
+         if(name)     free(name);
+         if(filetype) free(filetype);
+         if(paramter) free(paramter);
+         continue;
+       }
 
        switch(i) //TODO: same problem here: only 3 associations supported
        {
@@ -448,6 +454,9 @@ unsigned char pnd_pxml_parse ( const char *pFilename, char *buffer, unsigned int
          app->associationitem3_parameter = paramter;
        }
        }
+       if(name)     free(name);
+       if(filetype) free(filetype);
+       if(paramter) free(paramter);
       }
     }
 
@@ -475,6 +484,7 @@ unsigned char pnd_pxml_parse ( const char *pFilename, char *buffer, unsigned int
        if ( ( t = pnd_pxml_get_attribute(pElem, PND_PXML_ATTRNAME_MKDIRPATH) ) ) {
          // first <dir>, so just replace it wholesale; we use strdup so we can free() easily later, consistently. Mmm, leak seems imminent.
          app -> mkdir_sp = strdup ( t );
+         free(t); // free this attribute
        }
 
        while ( ( pElem = pElem -> NextSiblingElement ( PND_PXML_ENAME_MKDIR ) ) ) {
@@ -488,6 +498,7 @@ unsigned char pnd_pxml_parse ( const char *pFilename, char *buffer, unsigned int
              app -> mkdir_sp = foo;
            } // assuming we got ram, lets cat it all together
 
+           free(t); // free this attribute
          } // got another elem?
 
        } // while