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

[PATCH] index-pack: do not segfault when keep_name is NULL

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Mar 16, 2014, 13:35 UTC
Message-ID
<1394976904-15395-3-git-send-email-pclouds@gmail.com>
In-Reply-To
<1394976904-15395-1-git-send-email-pclouds@gmail.com>

keep_name is used to print error messages a couple lines down. Reset it to the real path returned by odb_pack_keep() if it's set to NULL by caller.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 One of these moments I will make git log and friends optionally recognize
 "Diff-Options:" line in commit message. Adding -U14 in this case
 should help the reviewer to see how those error messages are printed.
 builtin/index-pack.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index a6b1c17..d95c3dc 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -1283,9 +1283,10 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
 	if (keep_msg) {
 		int keep_fd, keep_msg_len = strlen(keep_msg);
 
-		if (!keep_name)
+		if (!keep_name) {
 			keep_fd = odb_pack_keep(name, sizeof(name), sha1);
-		else
+			keep_name = name;
+		} else
 			keep_fd = open(keep_name, O_RDWR|O_CREAT|O_EXCL, 0600);
 
 		if (keep_fd < 0) {
-- 
1.9.0.40.gaa8c3ea
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 3 of 21 in “Better "gc --aggressive"”
  1. 0/4 Better "gc --aggressive"Nguyễn Thái Ngọc Duy, Mar 16, 2014
  2. 1/4 environment.c: fix constness for odb_pack_keep()Nguyễn Thái Ngọc Duy, Mar 16, 2014
  3. index-pack: do not segfault when keep_name is NULLNguyễn Thái Ngọc Duy, Mar 16, 2014
  4. 2/4 pack-objects: support --keepNguyễn Thái Ngọc Duy, Mar 16, 2014
  5. 3/4 gc --aggressive: make --depth configurableNguyễn Thái Ngọc Duy, Mar 16, 2014
  6. 4/4 gc --aggressive: three phase repackingNguyễn Thái Ngọc Duy, Mar 16, 2014
  7. Junio C HamanoMar 17, 2014
  8. Duy NguyenMar 17, 2014
  9. Junio C HamanoMar 17, 2014
  10. Jeff KingMar 18, 2014
  11. Duy NguyenMar 18, 2014
  12. Jeff KingMar 18, 2014
  13. David KastrupMar 18, 2014
  14. Duy NguyenMar 19, 2014
  15. Jeff KingMar 18, 2014
  16. Duy NguyenMar 18, 2014
  17. Duy NguyenMar 18, 2014
  18. David KastrupMar 18, 2014
  19. David KastrupMar 18, 2014
  20. Duy NguyenMar 16, 2014
  21. Duy NguyenMar 20, 2014

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.