From 5fd7d584ceae84e8d37491c65bde9ffb9ed46066 Mon Sep 17 00:00:00 2001 From: Meep-Eep Date: Wed, 21 Dec 2011 18:03:45 +0000 Subject: [PATCH] Fix memory leak, from louisdx. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3709 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/ChangeLog | 1 + sc2/src/libs/file/dirs.c | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 87545d6f9..1ce865944 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,5 @@ Changes towards version 0.8: +- Fix memory leak in mkdirhier(), from Loius Delacroix - Some cleanups / warnings fixes, from Louis Delacroix - Added a free callback function for the values of the key-value pairs in hash tables - SvdB diff --git a/sc2/src/libs/file/dirs.c b/sc2/src/libs/file/dirs.c index 4b2c5f65c..39a44f5e5 100644 --- a/sc2/src/libs/file/dirs.c +++ b/sc2/src/libs/file/dirs.c @@ -142,7 +142,7 @@ mkdirhier (const char *path) if (*pathstart == '\0') { // path exists completely, nothing more to do - return 0; + goto success; } // walk through the path as long as the components exist @@ -177,7 +177,7 @@ mkdirhier (const char *path) } if (*pathend == '\0') - return 0; + goto success; *ptr = '/'; ptr++; @@ -187,7 +187,7 @@ mkdirhier (const char *path) // pathstart is the next non-slash character if (*pathstart == '\0') - return 0; + goto success; } // create all components left @@ -221,6 +221,9 @@ mkdirhier (const char *path) ptr += pathend - pathstart; *ptr = '\0'; } + +success: + HFree (buf); return 0; err: @@ -641,6 +644,7 @@ expandPath (char *dest, size_t len, const char *src, int what) *destptr = '\0'; } + HFree (buf); return 0; err: