]> git.ipfire.org Git - thirdparty/git.git/commitdiff
fsmonitor: avoid memory leak in `fsm_settings__get_incompatible_msg()`
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Wed, 15 Jun 2022 23:35:36 +0000 (23:35 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 16 Jun 2022 20:22:03 +0000 (13:22 -0700)
Reported by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
fsmonitor-settings.c

index 658cb79da0123b900a31b7205582edde196eded7..464424a1e924c63073a501fc0b9c030904074314 100644 (file)
@@ -202,11 +202,15 @@ char *fsm_settings__get_incompatible_msg(const struct repository *r,
        case FSMONITOR_REASON_OK:
                goto done;
 
-       case FSMONITOR_REASON_BARE:
+       case FSMONITOR_REASON_BARE: {
+               char *cwd = xgetcwd();
+
                strbuf_addf(&msg,
                            _("bare repository '%s' is incompatible with fsmonitor"),
-                           xgetcwd());
+                           cwd);
+               free(cwd);
                goto done;
+       }
 
        case FSMONITOR_REASON_ERROR:
                strbuf_addf(&msg,