ref_transaction_create(): check that new_sha1 is valid
authorMichael Haggerty <mhagger@alum.mit.edu>
Tue, 17 Feb 2015 17:00:19 +0000 (18:00 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 17 Feb 2015 19:24:48 +0000 (11:24 -0800)
Creating a reference requires a new_sha1 that is not NULL and not
null_sha1.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Reviewed-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c
diff --git a/refs.c b/refs.c
index e3c4ab5fd56e07dbeb49e6142cb9e80e7d6ff0fa..b9cf284f310d52d0be34fd51b236e08cdfc2f9c0 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -3690,6 +3690,8 @@ int ref_transaction_create(struct ref_transaction *transaction,
                           unsigned int flags, const char *msg,
                           struct strbuf *err)
 {
+       if (!new_sha1 || is_null_sha1(new_sha1))
+               die("BUG: create called without valid new_sha1");
        return ref_transaction_update(transaction, refname, new_sha1,
                                      null_sha1, flags, msg, err);
 }