Fix memory leak, from louisdx.

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3709 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
Meep-Eep
2011-12-21 18:03:45 +00:00
parent 706dbb3cd9
commit 5fd7d584ce
2 changed files with 8 additions and 3 deletions
+1
View File
@@ -1,4 +1,5 @@
Changes towards version 0.8: Changes towards version 0.8:
- Fix memory leak in mkdirhier(), from Loius Delacroix
- Some cleanups / warnings fixes, from Louis Delacroix - Some cleanups / warnings fixes, from Louis Delacroix
- Added a free callback function for the values of the key-value pairs - Added a free callback function for the values of the key-value pairs
in hash tables - SvdB in hash tables - SvdB
+7 -3
View File
@@ -142,7 +142,7 @@ mkdirhier (const char *path)
if (*pathstart == '\0') { if (*pathstart == '\0') {
// path exists completely, nothing more to do // path exists completely, nothing more to do
return 0; goto success;
} }
// walk through the path as long as the components exist // walk through the path as long as the components exist
@@ -177,7 +177,7 @@ mkdirhier (const char *path)
} }
if (*pathend == '\0') if (*pathend == '\0')
return 0; goto success;
*ptr = '/'; *ptr = '/';
ptr++; ptr++;
@@ -187,7 +187,7 @@ mkdirhier (const char *path)
// pathstart is the next non-slash character // pathstart is the next non-slash character
if (*pathstart == '\0') if (*pathstart == '\0')
return 0; goto success;
} }
// create all components left // create all components left
@@ -221,6 +221,9 @@ mkdirhier (const char *path)
ptr += pathend - pathstart; ptr += pathend - pathstart;
*ptr = '\0'; *ptr = '\0';
} }
success:
HFree (buf);
return 0; return 0;
err: err:
@@ -641,6 +644,7 @@ expandPath (char *dest, size_t len, const char *src, int what)
*destptr = '\0'; *destptr = '\0';
} }
HFree (buf);
return 0; return 0;
err: err: