Skip to content

Commit 6816601

Browse files
authored
Merge pull request libgit2#4948 from libgit2/ethomson/memleaks
repository: free memory in symlink detection function
2 parents 1e92a03 + b8b796c commit 6816601

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/repository.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,10 @@ static bool is_filesystem_case_insensitive(const char *gitdir_path)
14151415
static bool are_symlinks_supported(const char *wd_path)
14161416
{
14171417
git_config *config = NULL;
1418+
git_buf global_buf = GIT_BUF_INIT;
1419+
git_buf xdg_buf = GIT_BUF_INIT;
1420+
git_buf system_buf = GIT_BUF_INIT;
1421+
git_buf programdata_buf = GIT_BUF_INIT;
14181422
git_buf path = GIT_BUF_INIT;
14191423
int fd;
14201424
struct stat st;
@@ -1428,11 +1432,6 @@ static bool are_symlinks_supported(const char *wd_path)
14281432
* _not_ set, then we do not test or enable symlink support.
14291433
*/
14301434
#ifdef GIT_WIN32
1431-
git_buf global_buf = GIT_BUF_INIT;
1432-
git_buf xdg_buf = GIT_BUF_INIT;
1433-
git_buf system_buf = GIT_BUF_INIT;
1434-
git_buf programdata_buf = GIT_BUF_INIT;
1435-
14361435
git_config_find_global(&global_buf);
14371436
git_config_find_xdg(&xdg_buf);
14381437
git_config_find_system(&system_buf);
@@ -1461,6 +1460,10 @@ static bool are_symlinks_supported(const char *wd_path)
14611460
(void)p_unlink(path.ptr);
14621461

14631462
done:
1463+
git_buf_dispose(&global_buf);
1464+
git_buf_dispose(&xdg_buf);
1465+
git_buf_dispose(&system_buf);
1466+
git_buf_dispose(&programdata_buf);
14641467
git_buf_dispose(&path);
14651468
git_config_free(config);
14661469
return symlinks != 0;

0 commit comments

Comments
 (0)