git-config: fix regexp memory leaks on error conditions
commit97ed50f93ba592b50278a8161282e862cb87b4c0
authorJeff King <peff@peff.net>
Tue, 23 Oct 2012 19:40:06 +0000 (23 15:40 -0400)
committerJeff King <peff@peff.net>
Wed, 24 Oct 2012 07:36:54 +0000 (24 03:36 -0400)
tree6a68b9a01826980d5ca7486b83c4eb618c0fe090
parent35998c89381a56b28433852386986aafde92428d
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>
builtin/config.c
config.c