git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/6] Protect peel_ref fallback case from NULL parse_object result

From
Shawn O. Pearce <spearce@spearce.org>
Date
Feb 24, 2008, 08:07 UTC
Message-ID
<20080224080719.GA22587@spearce.org>

If the SHA-1 we are requesting the object for does not exist in the object database we get a NULL back. Accessing the type from that is not likely to succeed on any system.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 refs.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/refs.c b/refs.c
index 67d2a50..fb33da1 100644
--- a/refs.c
+++ b/refs.c
@@ -506,7 +506,7 @@ int peel_ref(const char *ref, unsigned char *sha1)
 
 	/* fallback - callers should not call this for unpacked refs */
 	o = parse_object(base);
-	if (o->type == OBJ_TAG) {
+	if (o && o->type == OBJ_TAG) {
 		o = deref_tag(o, ref, 0);
 		if (o) {
 			hashcpy(sha1, o->sha1);
-- 
1.5.4.3.295.g6b554
Message 1 of 1 in “Protect peel_ref fallback case from NULL parse_object result”
  1. 1/6 Protect peel_ref fallback case from NULL parse_object resultShawn O. Pearce, Feb 24, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.