summaryrefslogtreecommitdiffstats
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
commit8c48ca9d4605032f3756e520f3afe9785f46f0f6 (patch)
tree7b08a0ed683e4a37498901bb225bc3cac6250737
parent31821e10331e5275bfb2b572454feb58c607bef1 (diff)
downloadpw-darwin-8c48ca9d4605032f3756e520f3afe9785f46f0f6.tar.gz
pw-darwin-8c48ca9d4605032f3756e520f3afe9785f46f0f6.tar.zst
pw-darwin-8c48ca9d4605032f3756e520f3afe9785f46f0f6.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
-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';
/*