Commit 5de261fe1da72d717a12aadc5ef8dc89b06c4556

Stefan Sperling 2018-03-11T12:01:54

fix mem leak in worktree test code

diff --git a/regress/worktree/worktree_test.c b/regress/worktree/worktree_test.c
index 7e70195..dd50f89 100644
--- a/regress/worktree/worktree_test.c
+++ b/regress/worktree/worktree_test.c
@@ -104,13 +104,15 @@ check_meta_file_exists(const char *worktree_path, const char *name)
 {
 	struct stat sb;
 	char *path;
+	int ret = 0;
 
 	if (asprintf(&path, "%s/%s/%s", worktree_path, GOT_WORKTREE_GOT_DIR,
 	    name) == -1)
 		return 0;
-	if (stat(path, &sb) == -1)
-		return 0;
-	return 1;
+	if (stat(path, &sb) == 0)
+		ret = 1;
+	free(path);
+	return ret;
 }
 
 static int