ref_transaction_create(): check that new_sha1 is valid

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>

Michael Haggerty committed Feb 17, 2015 at 18:00 UTC f04c5b5522214cd48b39399d1d26b07848fd0e52
1 file changed +2
refs.c
+2
@@ -3690,6 +3690,8 @@ int ref_transaction_create(struct ref_transaction *transaction,
3690 unsigned int flags, const char *msg,
3691 struct strbuf *err)
3692 {
3693 + if (!new_sha1 || is_null_sha1(new_sha1))
3694 + die("BUG: create called without valid new_sha1");
3695 return ref_transaction_update(transaction, refname, new_sha1,
3696 null_sha1, flags, msg, err);
3697 }