summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2012-10-23 19:40:06 (GMT)
committerJeff King <peff@peff.net>2012-10-24 07:36:54 (GMT)
commit97ed50f93ba592b50278a8161282e862cb87b4c0 (patch)
tree6a68b9a01826980d5ca7486b83c4eb618c0fe090 /config.c
parent35998c89381a56b28433852386986aafde92428d (diff)
downloadgit-97ed50f93ba592b50278a8161282e862cb87b4c0.zip
git-97ed50f93ba592b50278a8161282e862cb87b4c0.tar.gz
git-97ed50f93ba592b50278a8161282e862cb87b4c0.tar.bz2
git-config: fix regexp memory leaks on error conditions
The get_value function has a goto label for cleaning up on errors, but it only cleans up half of what the function might allocate. Let's also clean up the key and regexp variables there. Note that we need to take special care when compiling the regex fails to clean it up ourselves, since it is in a half-constructed state (we would want to free it, but not regfree it). Similarly, we fix git_config_parse_key to return NULL when it fails, not a pointer to some already-freed memory. Signed-off-by: Jeff King <peff@peff.net>
Diffstat (limited to 'config.c')
-rw-r--r--config.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/config.c b/config.c
index 08e47e2..2fbe634 100644
--- a/config.c
+++ b/config.c
@@ -1280,6 +1280,7 @@ int git_config_parse_key(const char *key, char **store_key, int *baselen_)
out_free_ret_1:
free(*store_key);
+ *store_key = NULL;
return -CONFIG_INVALID_KEY;
}