properly free memory/close fd upon errors (Thanks xeen)

Found with the static analyzer cppcheck
This commit is contained in:
Michael Stapelberg
2011-08-31 14:44:48 +02:00
parent 69dc632a4e
commit e1631d6320
3 changed files with 6 additions and 1 deletions

View File

@ -59,8 +59,10 @@ static bool mkdirp(const char *path) {
copy[strlen(copy)-1] = '\0';
char *sep = strrchr(copy, '/');
if (sep == NULL)
if (sep == NULL) {
FREE(copy);
return false;
}
*sep = '\0';
bool result = false;
if (mkdirp(copy))