fsmonitor: avoid memory leak in `fsm_settings__get_incompatible_msg()`
Reported by Coverity. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Jun 15, 2022 at 23:35 UTC
5a09991e32f3487702bd032703bacba1c4c46612
1 file changed
+6
-2
fsmonitor-settings.c
+6
-2
@@ -202,11 +202,15 @@ char *fsm_settings__get_incompatible_msg(const struct repository *r,
202
case FSMONITOR_REASON_OK:
203
goto done;
204
205
- case FSMONITOR_REASON_BARE:
205
+ case FSMONITOR_REASON_BARE: {
206
+ char *cwd = xgetcwd();
207
+
208
strbuf_addf(&msg,
209
_("bare repository '%s' is incompatible with fsmonitor"),
208
- xgetcwd());
210
+ cwd);
211
+ free(cwd);
212
goto done;
213
+ }
214
215
case FSMONITOR_REASON_ERROR:
216
strbuf_addf(&msg,