]> granicus.if.org Git - git/commitdiff
receive-pack: don't access hash of NULL object_id pointer
authorRené Scharfe <l.s.r@web.de>
Sat, 15 Jul 2017 18:33:54 +0000 (20:33 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 17 Jul 2017 21:51:32 +0000 (14:51 -0700)
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>
builtin/receive-pack.c

index b1706a5731c0e527a8abc1d42ac4f0e6d346c47c..f589e8aebfd4066b789f2c50864cef831115260a 100644 (file)
@@ -1137,7 +1137,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)
                }
                if (ref_transaction_delete(transaction,
                                           namespaced_name,
-                                          old_oid->hash,
+                                          old_oid ? old_oid->hash : NULL,
                                           0, "push", &err)) {
                        rp_error("%s", err.buf);
                        strbuf_release(&err);