diff options
| author | Patrick Steinhardt <ps@pks.im> | 2024-08-01 12:40:21 +0200 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-08-01 08:47:36 -0700 |
| commit | 2d197e4a0f34b97b03416666bebcb993e41fed26 (patch) | |
| tree | d02e8d86af266c6c7e7fc33b7495379126f67a38 /t/t1502-rev-parse-parseopt.sh | |
| parent | 2e875b6cb408351c07919efb024ee1b52e0a3ac3 (diff) | |
| download | git-2d197e4a0f34b97b03416666bebcb993e41fed26.tar.xz | |
builtin/rev-parse: fix memory leak with `--parseopt`
The `--parseopt` mode allows shell scripts to have the same option
parsing mode as we have in C builtins. It soaks up a set of option
descriptions via stdin and massages them into proper `struct option`s
that we can then use to parse a set of arguments.
We only partially free those options when done though, creating a memory
leak. Interestingly, we only end up free'ing the first option's help,
which is of course wrong.
Fix this by freeing all option's help fields as well as their `argh`
fields to plug this memory leak.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1502-rev-parse-parseopt.sh')
| -rwxr-xr-x | t/t1502-rev-parse-parseopt.sh | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/t/t1502-rev-parse-parseopt.sh b/t/t1502-rev-parse-parseopt.sh index b754b9fd74..5eaa6428c4 100755 --- a/t/t1502-rev-parse-parseopt.sh +++ b/t/t1502-rev-parse-parseopt.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='test git rev-parse --parseopt' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh check_invalid_long_option () { |
