File 0003-repository-free-memory-in-symlink-detection-function.patch of Package libgit2.25920

From b8b796c14a29e07f4cbc0e4413c1c1bc3affddd8 Mon Sep 17 00:00:00 2001
From: Edward Thomson <ethomson@edwardthomson.com>
Date: Sun, 20 Jan 2019 18:09:43 +0000
Subject: [PATCH] repository: free memory in symlink detection function

---
 src/repository.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/repository.c b/src/repository.c
index 21e44351f9d..0f38f88f2d1 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -1415,6 +1415,10 @@ static bool is_filesystem_case_insensitive(const char *gitdir_path)
 static bool are_symlinks_supported(const char *wd_path)
 {
 	git_config *config = NULL;
+	git_buf global_buf = GIT_BUF_INIT;
+	git_buf xdg_buf = GIT_BUF_INIT;
+	git_buf system_buf = GIT_BUF_INIT;
+	git_buf programdata_buf = GIT_BUF_INIT;
 	git_buf path = GIT_BUF_INIT;
 	int fd;
 	struct stat st;
@@ -1428,11 +1432,6 @@ static bool are_symlinks_supported(const char *wd_path)
 	 * _not_ set, then we do not test or enable symlink support.
 	 */
 #ifdef GIT_WIN32
-	git_buf global_buf = GIT_BUF_INIT;
-	git_buf xdg_buf = GIT_BUF_INIT;
-	git_buf system_buf = GIT_BUF_INIT;
-	git_buf programdata_buf = GIT_BUF_INIT;
-
 	git_config_find_global(&global_buf);
 	git_config_find_xdg(&xdg_buf);
 	git_config_find_system(&system_buf);
@@ -1461,6 +1460,10 @@ static bool are_symlinks_supported(const char *wd_path)
 	(void)p_unlink(path.ptr);
 
 done:
+	git_buf_free(&global_buf);
+	git_buf_free(&xdg_buf);
+	git_buf_free(&system_buf);
+	git_buf_free(&programdata_buf);
 	git_buf_free(&path);
 	git_config_free(config);
# 	return symlinks != 0;
 	return symlinks;
openSUSE Build Service is sponsored by