Commit 27f50a66124054518d5febe984bccad02ee0846b

Miguel Arroz 2021-09-02T18:59:19

#6028: Check if `threadstate->error_t.message` is not `git_buf__initbuf` before freeing. This follows the same principle as `buffer.c` where the same check is done before freeing the buffer. It fixes the crash described in #6028.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/src/threadstate.c b/src/threadstate.c
index 6031e82..e2c0897 100644
--- a/src/threadstate.c
+++ b/src/threadstate.c
@@ -36,7 +36,8 @@ static void threadstate_dispose(git_threadstate *threadstate)
 	if (!threadstate)
 		return;
 
-	git__free(threadstate->error_t.message);
+    if (threadstate->error_t.message != git_buf__initbuf)
+        git__free(threadstate->error_t.message);
 	threadstate->error_t.message = NULL;
 }