tree-diff: don't access hash of NULL object_id pointer
[gitweb.git] / notes-cache.c
index 1cdd4984a4c53b86aad398a241f7a630b7758b36..29b4cede5f8d539416d0af22f31b0aabc0e28c46 100644 (file)
@@ -14,7 +14,7 @@ static int notes_cache_match_validity(const char *ref, const char *validity)
        if (read_ref(ref, oid.hash) < 0)
                return 0;
 
-       commit = lookup_commit_reference_gently(oid.hash, 1);
+       commit = lookup_commit_reference_gently(&oid, 1);
        if (!commit)
                return 0;
 
@@ -69,15 +69,15 @@ int notes_cache_write(struct notes_cache *c)
 char *notes_cache_get(struct notes_cache *c, struct object_id *key_oid,
                      size_t *outsize)
 {
-       const unsigned char *value_sha1;
+       const struct object_id *value_oid;
        enum object_type type;
        char *value;
        unsigned long size;
 
-       value_sha1 = get_note(&c->tree, key_oid->hash);
-       if (!value_sha1)
+       value_oid = get_note(&c->tree, key_oid);
+       if (!value_oid)
                return NULL;
-       value = read_sha1_file(value_sha1, &type, &size);
+       value = read_sha1_file(value_oid->hash, &type, &size);
 
        *outsize = size;
        return value;
@@ -90,5 +90,5 @@ int notes_cache_put(struct notes_cache *c, struct object_id *key_oid,
 
        if (write_sha1_file(data, size, "blob", value_oid.hash) < 0)
                return -1;
-       return add_note(&c->tree, key_oid->hash, value_oid.hash, NULL);
+       return add_note(&c->tree, key_oid, &value_oid, NULL);
 }