summary refs log tree commit diff
path: root/notes-cache.c
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2017-05-30 10:30:40 -0700
committerJunio C Hamano <gitster@pobox.com>2017-06-02 09:36:06 +0900
commit9ef7223058a44990dc4650ecb1209c97ceb636b3 (patch)
treee3aa8240bac2be6a2bf5ad158023ec31a67d3457 /notes-cache.c
parent490bc83a01acfefa11e98f8852b1f4a9dd962331 (diff)
notes: make get_note return pointer to struct object_id
Make get_note return a pointer to a const struct object_id.  Add a
defensive check to ensure we don't accidentally dereference a NULL
pointer.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'notes-cache.c')
-rw-r--r--notes-cache.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/notes-cache.c b/notes-cache.c
index 2843e98576..6e84a748f0 100644
--- a/notes-cache.c
+++ b/notes-cache.c
@@ -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->hash);
+	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;