Commit fe4c750
submodule--helper: fix a configure_added_submodule() leak
Fix config API a memory leak added in a452128 (submodule--helper:
introduce add-config subcommand, 2021-08-06) by using the *_tmp()
variant of git_config_get_string().
In this case we're only checking whether
the (repo|git)_config_get_string() call is telling us that the
"submodule.active" key exists.
As with the preceding commit we'll find many other such patterns in
the codebase if we go fishing. E.g. "git gc" leaks in the code added
in 61f7a38 (maintenance: use 'incremental' strategy by default,
2020-10-15). Similar code in "git gc" added in
b08ff1f (maintenance: add --schedule option and config,
2020-09-11) doesn't leak, but we could avoid the malloc() & free() in
that case.
A coccinelle rule to find those would find and fix some leaks, and
cases where we're doing needless malloc() + free()'s but only care
about the key existence, or are copying
the (repo|git)_config_get_string() return value right away.
But as with the preceding commit let's punt on all of that for now,
and just narrowly fix this specific case in submodule--helper.
Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]>
Reviewed-by: Glen Choo <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>1 parent 4c4d3e7 commit fe4c750
2 files changed
+3
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3157 | 3157 | | |
3158 | 3158 | | |
3159 | 3159 | | |
3160 | | - | |
| 3160 | + | |
3161 | 3161 | | |
3162 | 3162 | | |
3163 | 3163 | | |
| |||
3202 | 3202 | | |
3203 | 3203 | | |
3204 | 3204 | | |
3205 | | - | |
| 3205 | + | |
3206 | 3206 | | |
3207 | 3207 | | |
3208 | 3208 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
0 commit comments