index-pack: report error using the correct variable
authorJunio C Hamano <gitster@pobox.com>
Mon, 17 Mar 2014 22:08:36 +0000 (15:08 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 17 Mar 2014 22:08:36 +0000 (15:08 -0700)
We feed a string pointer that is potentially NULL to die() when
showing the message. Don't.

Noticed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/index-pack.c
index 9e9eb4b74e8335f097c7cc9e261b051feda0bf0d..80c937413529153117e8e0fe0f205c5ef66de040 100644 (file)
@@ -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";
                }
        }