summaryrefslogtreecommitdiff
path: root/src/pack-objects.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2016-02-09 10:53:30 +0100
committerPatrick Steinhardt <ps@pks.im>2016-02-09 10:53:30 +0100
commit39c9dd24d3556bc4eec584ac2165f2a01de64da1 (patch)
tree496cdc9a0eeef03c12ce81a7a7f92c6d24c9b874 /src/pack-objects.c
parent0b2437bb680897424e208464312fe2d4610cc4b6 (diff)
downloadlibgit2-39c9dd24d3556bc4eec584ac2165f2a01de64da1.tar.gz
pack-objects: fix memory leak in packbuilder_config
Diffstat (limited to 'src/pack-objects.c')
-rw-r--r--src/pack-objects.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/pack-objects.c b/src/pack-objects.c
index 3046d941d..0afa28e62 100644
--- a/src/pack-objects.c
+++ b/src/pack-objects.c
@@ -91,7 +91,7 @@ static unsigned name_hash(const char *name)
static int packbuilder_config(git_packbuilder *pb)
{
git_config *config;
- int ret;
+ int ret = 0;
int64_t val;
if ((ret = git_repository_config_snapshot(&config, pb->repo)) < 0)
@@ -100,8 +100,10 @@ static int packbuilder_config(git_packbuilder *pb)
#define config_get(KEY,DST,DFLT) do { \
ret = git_config_get_int64(&val, config, KEY); \
if (!ret) (DST) = val; \
- else if (ret == GIT_ENOTFOUND) (DST) = (DFLT); \
- else if (ret < 0) return -1; } while (0)
+ else if (ret == GIT_ENOTFOUND) { \
+ (DST) = (DFLT); \
+ ret = 0; \
+ } else if (ret < 0) goto out; } while (0)
config_get("pack.deltaCacheSize", pb->max_delta_cache_size,
GIT_PACK_DELTA_CACHE_SIZE);
@@ -113,9 +115,10 @@ static int packbuilder_config(git_packbuilder *pb)
#undef config_get
+out:
git_config_free(config);
- return 0;
+ return ret;
}
int git_packbuilder_new(git_packbuilder **out, git_repository *repo)