Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
update-index: fix xgetcwd() related memory leak
author
Christian Couder
<christian.couder@gmail.com>
Thu, 30 Mar 2017 06:22:08 +0000
(08:22 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Thu, 30 Mar 2017 17:33:31 +0000
(10:33 -0700)
As xgetcwd() returns an allocated buffer, we should free this
buffer when we don't need it any more.
This was found by Coverity.
Reported-by: Jeff King <peff@peff.net>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/update-index.c
patch
|
blob
|
history
raw
|
patch
| inline |
side by side
(parent:
7c12178
)
diff --git
a/builtin/update-index.c
b/builtin/update-index.c
index 7a5533491eb19ca48556d1fa20bf7cdaf5b50903..984fe37da1b2f7f95b5e3e9e0eef4f61d176fafc 100644
(file)
--- a/
builtin/update-index.c
+++ b/
builtin/update-index.c
@@
-125,12
+125,16
@@
static int test_if_untracked_cache_is_supported(void)
struct stat st;
struct stat_data base;
int fd, ret = 0;
+ char *cwd;
strbuf_addstr(&mtime_dir, "mtime-test-XXXXXX");
if (!mkdtemp(mtime_dir.buf))
die_errno("Could not make temporary directory");
- fprintf(stderr, _("Testing mtime in '%s' "), xgetcwd());
+ cwd = xgetcwd();
+ fprintf(stderr, _("Testing mtime in '%s' "), cwd);
+ free(cwd);
+
atexit(remove_test_directory);
xstat_mtime_dir(&st);
fill_stat_data(&base, &st);