From 42db44510d6e58120a9f0d272f5de2b26fb09ba7 Mon Sep 17 00:00:00 2001
From: Dirk Hohndel <dirk@hohndel.org>
Date: Tue, 26 Dec 2017 14:17:54 -0800
Subject: [PATCH] Cleanup: avoid memory leak

Coverity CID 208333

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
---
 core/save-git.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/core/save-git.c b/core/save-git.c
index 27051ec39..e5ff5378b 100644
--- a/core/save-git.c
+++ b/core/save-git.c
@@ -1099,7 +1099,9 @@ static void create_commit_message(struct membuffer *msg, bool create_empty)
 		} while ((dc = dc->next) != NULL);
 		put_format(msg, "\n");
 	}
-	put_format(msg, "Created by %s\n", subsurface_user_agent());
+	const char *user_agent = subsurface_user_agent();
+	put_format(msg, "Created by %s\n", user_agent);
+	free((void *)user_agent);
 }
 
 static int create_new_commit(git_repository *repo, const char *remote, const char *branch, git_oid *tree_id, bool create_empty)