Skip to content

Commit

Permalink
bee-dep: fix creation of BEE_CACHEDIR
Browse files Browse the repository at this point in the history
see dirname(3): RETURN VALUE
Both  dirname()  and basename() return pointers to null-terminated strings.
(Do not pass these pointers to free(3).)
  • Loading branch information
mariux committed Dec 16, 2011
1 parent 7434169 commit cf859fc
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/bee-dep.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ int main(int argc, char *argv[])
int c, help, rebuild, update, remove, print, options;
char found;
char cachefile[PATH_MAX + 1], path[PATH_MAX + 1], tmp[PATH_MAX + 1];
char *bee_metadir, *bee_cachedir, *dir, *pkgname;
char *bee_metadir, *bee_cachedir, *pkgname;
struct hash *graph;
struct stat st;
FILE *cache;
Expand Down Expand Up @@ -272,16 +272,11 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}

dir = strdup(cachefile);
dir = dirname(dir);

if (mkdirp(dir, 0755) == -1) {
if (mkdirp(bee_cachedir, 0755) == -1) {
perror("bee-dep: mkdirp");
exit(EXIT_FAILURE);
}

free(dir);

graph = NULL;

found = (stat(cachefile, &st) != -1 && S_ISREG(st.st_mode));
Expand Down

0 comments on commit cf859fc

Please sign in to comment.