Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-06-01 01:09:58 +0400
committerRussell Belfer <rb@github.com>2013-06-01 01:09:58 +0400
commitf658dc433cae351e72b1c8b245724eafb43f5844 (patch)
tree025948ea3b6a30c41b44d86fe4655fbeda3d578c /src/pack.c
parent17ef7dbce4e4eaa08ed7007b6d67f375759846a8 (diff)
Zero memory for major objects before freeing
By zeroing out the memory when we free larger objects (i.e. those that serve as collections of other data, such as repos, odb, refdb), I'm hoping that it will be easier for libgit2 bindings to find errors in their object management code.
Diffstat (limited to 'src/pack.c')
-rw-r--r--src/pack.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/pack.c b/src/pack.c
index 417d225f3..a9b835fca 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -85,13 +85,17 @@ static void cache_free(git_pack_cache *cache)
git_offmap_free(cache->entries);
git_mutex_free(&cache->lock);
}
+
+ memset(cache, 0, sizeof(*cache));
}
static int cache_init(git_pack_cache *cache)
{
- memset(cache, 0, sizeof(git_pack_cache));
+ memset(cache, 0, sizeof(*cache));
+
cache->entries = git_offmap_alloc();
GITERR_CHECK_ALLOC(cache->entries);
+
cache->memory_limit = GIT_PACK_CACHE_MEMORY_LIMIT;
git_mutex_init(&cache->lock);