Skip to content

Commit c4f9490

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5aa9e32 commit c4f9490

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fsmonitor.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,10 @@ void refresh_fsmonitor(struct index_state *istate)
309309
enum fsmonitor_reason reason = fsm_settings__get_reason(r);
310310

311311
if (!warn_once && reason > FSMONITOR_REASON_OK) {
312+
char *msg = fsm_settings__get_incompatible_msg(r, reason);
312313
warn_once = 1;
313-
warning("%s", fsm_settings__get_incompatible_msg(r, reason));
314+
warning("%s", msg);
315+
free(msg);
314316
}
315317

316318
if (fsm_mode <= FSMONITOR_MODE_DISABLED ||

0 commit comments

Comments
 (0)