[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