Commit 6b7476e9f2c7f6070401b1d58a55e87149f8151d

Stefan Sperling 2018-03-11T11:57:28

plug file descriptor leak in worktree test code

diff --git a/regress/worktree/worktree_test.c b/regress/worktree/worktree_test.c
index 1259b0c..030daff 100644
--- a/regress/worktree/worktree_test.c
+++ b/regress/worktree/worktree_test.c
@@ -170,6 +170,7 @@ obstruct_meta_file(char **path, const char *worktree_path, const char *name)
 {
 	FILE *f;
 	char *s = "This file should not be here\n";
+	int ret = 1;
 
 	if (asprintf(path, "%s/%s/%s", worktree_path, GOT_WORKTREE_GOT_DIR,
 	    name) == -1)
@@ -181,10 +182,10 @@ obstruct_meta_file(char **path, const char *worktree_path, const char *name)
 	}
 	if (fwrite(s, 1, strlen(s), f) != strlen(s)) {
 		free(*path);
-		return 0;
+		ret = 0;
 	}
 	fclose(f);
-	return 1;
+	return ret;
 }
 
 static int