Commit a44f885cd476faee2154cbae1a1dc47bdeaea727

Guillem Jover 2023-11-14T19:08:15

test: Fix short-lived memory leak Warned-by: cppcheck

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/test/pwcache.c b/test/pwcache.c
index ac1e67b..458903f 100644
--- a/test/pwcache.c
+++ b/test/pwcache.c
@@ -50,8 +50,10 @@ main(int argc, char **argv)
 	assert(uname != NULL);
 
 	gr = getgrgid(0);
-	if (gr == NULL)
+	if (gr == NULL) {
+		free(uname);
 		return TEST_SKIP;
+	}
 	gname = strdup(gr->gr_name);
 	assert(gname != NULL);