receive-pack: don't access hash of NULL object_id pointer

We set old_oid to NULL if we found out that it's a corrupt reference. In that case don't try to access the hash member and pass NULL to ref_transaction_delete() instead. Found with Clang's UBSan. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Jul 15, 2017 at 20:33 UTC f730944a49b2a210bb10520700c0a3f6c49bc020
1 file changed +1 -1
builtin/receive-pack.c
+1 -1
@@ -1137,7 +1137,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)
1137 }
1138 if (ref_transaction_delete(transaction,
1139 namespaced_name,
1140 - old_oid->hash,
1140 + old_oid ? old_oid->hash : NULL,
1141 0, "push", &err)) {
1142 rp_error("%s", err.buf);
1143 strbuf_release(&err);