diff options
| author | Adam Murray <ad@canva.com> | 2025-01-10 07:28:20 +0000 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-01-23 10:01:56 -0800 |
| commit | 2fd367cf63cd5f94368340cc6fe1cd0a3fb021df (patch) | |
| tree | 8543686f0704c7c216059771088b04be01778252 /trace2/tr2_tgt_perf.c | |
| parent | Git 2.46.3 (diff) | |
| download | git-2fd367cf63cd5f94368340cc6fe1cd0a3fb021df.tar.gz git-2fd367cf63cd5f94368340cc6fe1cd0a3fb021df.zip | |
trace2: prevent segfault on config collection with valueless true
When TRACE2 analytics is enabled, a configuration variable set to
"valueless true" causes a segfault.
Steps to Reproduce
GIT_TRACE2=true GIT_TRACE2_CONFIG_PARAMS=status.*
git -c status.relativePaths version
Expected Result
git version 2.46.0
Actual Result
zsh: segmentation fault GIT_TRACE2=true
Add checks to prevent the segfault and instead show that the
variable without value.
Signed-off-by: Adam Murray <ad@canva.com>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'trace2/tr2_tgt_perf.c')
| -rw-r--r-- | trace2/tr2_tgt_perf.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/trace2/tr2_tgt_perf.c b/trace2/tr2_tgt_perf.c index a6f9a8a193..19ae7433ef 100644 --- a/trace2/tr2_tgt_perf.c +++ b/trace2/tr2_tgt_perf.c @@ -446,8 +446,9 @@ static void fn_param_fl(const char *file, int line, const char *param, struct strbuf scope_payload = STRBUF_INIT; enum config_scope scope = kvi->scope; const char *scope_name = config_scope_name(scope); - - strbuf_addf(&buf_payload, "%s:%s", param, value); + strbuf_addstr(&buf_payload, param); + if (value) + strbuf_addf(&buf_payload, ":%s", value); strbuf_addf(&scope_payload, "%s:%s", "scope", scope_name); perf_io_write_fl(file, line, event_name, NULL, NULL, NULL, |
