From 4b7531ad98d318b8071d595ce3e0d4113ee06f93 Mon Sep 17 00:00:00 2001 From: Cloudef Date: Wed, 31 Aug 2011 17:53:22 +0300 Subject: [PATCH] Fix even more leaks --- lib/pnd_conf.c | 1 + lib/pnd_locate.c | 1 + lib/pnd_pxml.c | 9 ++++++++- lib/pnd_tinyxml.cpp | 13 ++++++++++++- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/pnd_conf.c b/lib/pnd_conf.c index 9c4f31f..824fbb3 100644 --- a/lib/pnd_conf.c +++ b/lib/pnd_conf.c @@ -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 ); } diff --git a/lib/pnd_locate.c b/lib/pnd_locate.c index 6e4afbb..1beb76c 100644 --- a/lib/pnd_locate.c +++ b/lib/pnd_locate.c @@ -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 ); } diff --git a/lib/pnd_pxml.c b/lib/pnd_pxml.c index 29e996d..77fc011 100644 --- a/lib/pnd_pxml.c +++ b/lib/pnd_pxml.c @@ -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 ); } diff --git a/lib/pnd_tinyxml.cpp b/lib/pnd_tinyxml.cpp index 577aef0..1aa8f9b 100644 --- a/lib/pnd_tinyxml.cpp +++ b/lib/pnd_tinyxml.cpp @@ -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 , 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 -- 2.39.5