diff options
author | Jeff King <peff@peff.net> | 2012-10-23 15:40:06 -0400 |
---|---|---|
committer | Jeff King <peff@peff.net> | 2012-10-24 03:36:54 -0400 |
commit | 97ed50f93ba592b50278a8161282e862cb87b4c0 (patch) | |
tree | 6a68b9a01826980d5ca7486b83c4eb618c0fe090 /config.c | |
parent | 35998c89381a56b28433852386986aafde92428d (diff) | |
download | git-97ed50f93ba592b50278a8161282e862cb87b4c0.tar.gz |
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.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -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; } |