Skip to content

Commit

Permalink
bee-dep: mkdirp() free(pdir) early and check for error later
Browse files Browse the repository at this point in the history
  • Loading branch information
mariux committed Dec 16, 2011
1 parent 5400ed5 commit 7434169
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/bee-dep.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ static FILE *open_and_lock(char *filename, char *mode)
int mkdirp(char *path, mode_t mode)
{
char *dir, *pdir, *end;
int ret;

assert(path);

Expand All @@ -180,12 +181,12 @@ int mkdirp(char *path, mode_t mode)
return -1;

/* create the directory ; ignore err if it already exists */
if(mkdir(pdir, mode) == -1 && errno != EEXIST) {
free(pdir);
return -1;
}
ret = mkdir(pdir, mode);

free(pdir);

if(ret == -1 && errno != EEXIST)
return -1;
}

return 0;
Expand Down

0 comments on commit 7434169

Please sign in to comment.