summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2017-07-15 20:15:26 +0200
committerJunio C Hamano <gitster@pobox.com>2017-07-17 14:51:07 -0700
commit3ea6b85a871aa41eaa66a2919451ad12d492c355 (patch)
treef99cc50988195a6385a961b1dabf0f502fbb8c55
parentfb04dced9c6510176f06953d2cd6a239703401f1 (diff)
downloadgit-3ea6b85a871aa41eaa66a2919451ad12d492c355.tar.gz
notes: don't access hash of NULL object_id pointer
Check if note is NULL, as we already do for different purposes a few lines above, and pass a NULL pointer to prepare_note_data() in that case instead of trying to access the hash member. Found with Clang's UBSan. Signed-off-by: Rene Scharfe <l.s.r@web.de> Acked-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/notes.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/notes.c b/builtin/notes.c
index 2ebc2b7c43..3d9dbc97a1 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -453,7 +453,7 @@ static int add(int argc, const char **argv, const char *prefix)
oid_to_hex(&object));
}
- prepare_note_data(&object, &d, note->hash);
+ prepare_note_data(&object, &d, note ? note->hash : NULL);
if (d.buf.len || allow_empty) {
write_note_data(&d, new_note.hash);
if (add_note(t, &object, &new_note, combine_notes_overwrite))