notes: don't access hash of NULL object_id pointer
[gitweb.git] / builtin / notes.c
index 2ebc2b7c43f433648f1156129f209747fbd6e184..3d9dbc97a1dd53c8baa20c39bcdb06e43b1c9e32 100644 (file)
@@ -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))