Commit 9e39acc
builtin/pack-objects.c: don't leak memory via arguments
When constructing arguments to pass to setup_revision(), pack-objects
only frees the memory used by that array after calling
get_object_list().
Ensure that we call strvec_clear() whether or not we use the arguments
array by cleaning up whenever we exit the function (and rewriting one
early return to jump to a label which frees the memory and then
returns).
We could avoid setting this array up altogether unless we are in the
if-else block that calls get_object_list(), but setting up the argument
array is intermingled with lots of other side-effects, e.g.:
if (exclude_promisor_objects) {
use_internal_rev_list = 1;
fetch_if_missing = 0;
strvec_push(&rp, "--exclude-promisor-objects");
}
So it would be awkward to check exclude_promisor_objects twice: first to
set use_internal_rev_list and fetch_if_missing, and then again above
get_object_list() to push the relevant argument onto the array.
Instead, leave the array's construction alone and make sure to free it
unconditionally.
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>1 parent 7f4c350 commit 9e39acc
1 file changed
+7
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4148 | 4148 | | |
4149 | 4149 | | |
4150 | 4150 | | |
4151 | | - | |
| 4151 | + | |
4152 | 4152 | | |
4153 | | - | |
| 4153 | + | |
4154 | 4154 | | |
4155 | | - | |
4156 | 4155 | | |
4157 | 4156 | | |
4158 | 4157 | | |
| |||
4162 | 4161 | | |
4163 | 4162 | | |
4164 | 4163 | | |
4165 | | - | |
| 4164 | + | |
4166 | 4165 | | |
4167 | 4166 | | |
4168 | 4167 | | |
| |||
4183 | 4182 | | |
4184 | 4183 | | |
4185 | 4184 | | |
| 4185 | + | |
| 4186 | + | |
| 4187 | + | |
| 4188 | + | |
4186 | 4189 | | |
4187 | 4190 | | |
0 commit comments