summaryrefslogtreecommitdiffstats
path: root/pw
diff options
context:
space:
mode:
authorBryan Drewery <bdrewery@FreeBSD.org>2015-10-29 18:29:28 +0000
committerBryan Drewery <bdrewery@FreeBSD.org>2015-10-29 18:29:28 +0000
commitd7268f1e76677b28d0ebecae94276c34bc8cba54 (patch)
treebb83c4043959538a63dcdec0600a5085889a8406 /pw
parent66d9e5fe286aaad023911a859e7b61e780a9740b (diff)
downloadpw-darwin-d7268f1e76677b28d0ebecae94276c34bc8cba54.tar.gz
pw-darwin-d7268f1e76677b28d0ebecae94276c34bc8cba54.tar.zst
pw-darwin-d7268f1e76677b28d0ebecae94276c34bc8cba54.zip
Fix unlikely memory leak.
It is unlikely since the first check in the function is that dir[0] is '/', but later code changes may make it real. Coverity CID: 1332104
Diffstat (limited to 'pw')
-rw-r--r--pw/pw_user.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/pw/pw_user.c b/pw/pw_user.c
index 1af8f81..345f642 100644
--- a/pw/pw_user.c
+++ b/pw/pw_user.c
@@ -107,8 +107,10 @@ mkdir_home_parents(int dfd, const char *dir)
errx(EX_UNAVAILABLE, "out of memory");
tmp = strrchr(dirs, '/');
- if (tmp == NULL)
+ if (tmp == NULL) {
+ free(dirs);
return;
+ }
tmp[0] = '\0';
/*