git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] setup.c: reset candidate->work_tree after freeing it

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Mar 30, 2018, 07:07 UTC
Message-ID
<20180330070744.22466-1-pclouds@gmail.com>
Dangling pointers are usually bad news. Reset it back to NULL.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/setup.c b/setup.c
index 7287779642..d193bee192 100644
--- a/setup.c
+++ b/setup.c
@@ -482,7 +482,7 @@ static int check_repository_format_gently(const char *gitdir, struct repository_
 			inside_work_tree = -1;
 		}
 	} else {
-		free(candidate->work_tree);
+		FREE_AND_NULL(candidate->work_tree);
 	}
 
 	return 0;
-- 
2.17.0.rc2.408.g9d2a3d914e
Next: Junio C Hamano
Message 1 of 5 in “setup.c: reset candidate->work_tree after freeing it”
  1. setup.c: reset candidate->work_tree after freeing itNguyễn Thái Ngọc Duy, Mar 30, 2018
  2. Junio C HamanoMar 30, 2018
  3. Duy NguyenMar 30, 2018
  4. Junio C HamanoMar 30, 2018
  5. Duy NguyenMar 30, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.