mirror of
https://github.com/git/git
synced 2024-08-27 11:39:22 +00:00
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>
This commit is contained in:
parent
fb04dced9c
commit
3ea6b85a87
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue