From 8c48ca9d4605032f3756e520f3afe9785f46f0f6 Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Thu, 29 Oct 2015 18:29:28 +0000 Subject: 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 --- pw/pw_user.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'pw/pw_user.c') 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'; /* -- cgit v1.2.3-56-ge451