Commit 819492c15435efc4a2e7278ba72a2888692f60de

Patrick Steinhardt 2020-09-18T10:34:40

refs: fix potential free of uninitialized variable The `signature` variable in `git_reference_rename` isn't initialized and neither does `git_reference__log_signature` always do. So if the latter function fails, we'll call `git_signature_free` on this unininitialized variable. Fix the issue by initializing the pointer with `NULL`.

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/src/refs.c b/src/refs.c
index ed90057..51635a9 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -606,7 +606,7 @@ int git_reference_rename(
 	const char *log_message)
 {
 	refs_update_head_payload payload;
-	git_signature *signature;
+	git_signature *signature = NULL;
 	git_repository *repo;
 	int error;