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>
René Scharfe committed
Jul 15, 2017 at 20:15 UTC
3ea6b85a871aa41eaa66a2919451ad12d492c355
1 file changed
+1
-1
builtin/notes.c
+1
-1
@@ -453,7 +453,7 @@ static int add(int argc, const char **argv, const char *prefix)
453
oid_to_hex(&object));
454
}
455
456
- prepare_note_data(&object, &d, note->hash);
456
+ prepare_note_data(&object, &d, note ? note->hash : NULL);
457
if (d.buf.len || allow_empty) {
458
write_note_data(&d, new_note.hash);
459
if (add_note(t, &object, &new_note, combine_notes_overwrite))