Free tmp string if dirname fails

This commit is contained in:
lostd 2014-10-22 17:21:53 +03:00
parent 9bc4b92474
commit 0809871aeb

View file

@ -128,8 +128,10 @@ xdirname(const char *path)
* original string if we lose track of it. */
tmp = xstrdup(path);
p = dirname(tmp);
if (p == NULL)
if (p == NULL) {
free(tmp);
printerr(1, "dirname");
}
/* Make sure this is a malloc(3)-ed string */
p = xstrdup(p);
free(tmp);