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

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

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Mar 17, 2014, 23:07 UTC
Message-ID
<1395097647-29362-1-git-send-email-pclouds@gmail.com>
In-Reply-To
<1394965862-8173-1-git-send-email-pclouds@gmail.com>

Use the name that is returned by odb_pack_keep() when the caller passes NULL in keep_name.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/index-pack.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index a6b1c17..b9f6e12 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -1291,7 +1291,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
 		if (keep_fd < 0) {
 			if (errno != EEXIST)
 				die_errno(_("cannot write keep file '%s'"),
-					  keep_name);
+					  keep_name ? keep_name : name);
 		} else {
 			if (keep_msg_len > 0) {
 				write_or_die(keep_fd, keep_msg, keep_msg_len);
@@ -1299,7 +1299,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
 			}
 			if (close(keep_fd) != 0)
 				die_errno(_("cannot close written keep file '%s'"),
-				    keep_name);
+					  keep_name ? keep_name : name);
 			report = "keep";
 		}
 	}
-- 
1.9.0.40.gaa8c3ea
Previous: Junio C Hamano
Message 3 of 3 in “index-pack: do not segfault when keep_name is NULL”
  1. index-pack: do not segfault when keep_name is NULLNguyễn Thái Ngọc Duy, Mar 16, 2014
  2. Junio C HamanoMar 17, 2014
  3. index-pack: do not segfault when keep_name is NULLNguyễn Thái Ngọc Duy, Mar 17, 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.