Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2022-10-11 03:42:38 +0300
committerJunio C Hamano <gitster@pobox.com>2022-10-11 08:16:56 +0300
commitc4f94907902f18d80a78ee19983d0d02932154d7 (patch)
tree3326c34d8419294b1689fd83172e28af6b9e825d /fsmonitor.c
parent5aa9e3262e6ac99c1c06d7f0e0619b1ea94a9881 (diff)
fsmonitor: fix leak of warning message
The fsm_settings__get_incompatible_msg() function returns an allocated string. So we can't pass its result directly to warning(); we must hold on to the pointer and free it to avoid a leak. The leak here is small and fixed size, but Coverity complained, and presumably SANITIZE=leaks would eventually. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fsmonitor.c')
-rw-r--r--fsmonitor.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/fsmonitor.c b/fsmonitor.c
index 540736b39f..08af00c738 100644
--- a/fsmonitor.c
+++ b/fsmonitor.c
@@ -309,8 +309,10 @@ void refresh_fsmonitor(struct index_state *istate)
enum fsmonitor_reason reason = fsm_settings__get_reason(r);
if (!warn_once && reason > FSMONITOR_REASON_OK) {
+ char *msg = fsm_settings__get_incompatible_msg(r, reason);
warn_once = 1;
- warning("%s", fsm_settings__get_incompatible_msg(r, reason));
+ warning("%s", msg);
+ free(msg);
}
if (fsm_mode <= FSMONITOR_MODE_DISABLED ||