update-index: fix xgetcwd() related memory leak
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>maint
parent
7c121788f4
commit
c105f563d1
|
@ -125,12 +125,16 @@ static int test_if_untracked_cache_is_supported(void)
|
||||||
struct stat st;
|
struct stat st;
|
||||||
struct stat_data base;
|
struct stat_data base;
|
||||||
int fd, ret = 0;
|
int fd, ret = 0;
|
||||||
|
char *cwd;
|
||||||
|
|
||||||
strbuf_addstr(&mtime_dir, "mtime-test-XXXXXX");
|
strbuf_addstr(&mtime_dir, "mtime-test-XXXXXX");
|
||||||
if (!mkdtemp(mtime_dir.buf))
|
if (!mkdtemp(mtime_dir.buf))
|
||||||
die_errno("Could not make temporary directory");
|
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);
|
atexit(remove_test_directory);
|
||||||
xstat_mtime_dir(&st);
|
xstat_mtime_dir(&st);
|
||||||
fill_stat_data(&base, &st);
|
fill_stat_data(&base, &st);
|
||||||
|
|
Loading…
Reference in New Issue