diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-09-19 10:47:55 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-09-19 10:47:55 +0900 |
commit | 09595ab3818619a34281b85e1fb98802182e12a2 (patch) | |
tree | 6f4074659713f2370682b7fc5c46d4e81573d60d /builtin/update-index.c | |
parent | df80c5760c947f2013df86f52d0a5103d07958a2 (diff) | |
parent | 0e5bba53af7d6f911e99589d736cdf06badad0fe (diff) | |
download | git-09595ab3818619a34281b85e1fb98802182e12a2.tar.gz git-09595ab3818619a34281b85e1fb98802182e12a2.tar.xz |
Merge branch 'jk/leak-checkers'
Many of our programs consider that it is OK to release dynamic
storage that is used throughout the life of the program by simply
exiting, but this makes it harder to leak detection tools to avoid
reporting false positives. Plug many existing leaks and introduce
a mechanism for developers to mark that the region of memory
pointed by a pointer is not lost/leaking to help these tools.
* jk/leak-checkers:
add UNLEAK annotation for reducing leak false positives
set_git_dir: handle feeding gitdir to itself
repository: free fields before overwriting them
reset: free allocated tree buffers
reset: make tree counting less confusing
config: plug user_config leak
update-index: fix cache entry leak in add_one_file()
add: free leaked pathspec after add_files_to_cache()
test-lib: set LSAN_OPTIONS to abort by default
test-lib: --valgrind should not override --verbose-log
Diffstat (limited to 'builtin/update-index.c')
-rw-r--r-- | builtin/update-index.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/builtin/update-index.c b/builtin/update-index.c index 655e6d60d..bf7420b80 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -287,8 +287,10 @@ static int add_one_path(const struct cache_entry *old, const char *path, int len } option = allow_add ? ADD_CACHE_OK_TO_ADD : 0; option |= allow_replace ? ADD_CACHE_OK_TO_REPLACE : 0; - if (add_cache_entry(ce, option)) + if (add_cache_entry(ce, option)) { + free(ce); return error("%s: cannot add to the index - missing --add option?", path); + } return 0; } |