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

[PATCH v2] revision.c: fix possible null pointer access

From
Stefan Naewe <stefan.naewe@gmail.com>
Date
Dec 5, 2015, 15:27 UTC
Message-ID
<1449329244-4585-1-git-send-email-stefan.naewe@gmail.com>
In-Reply-To
<xmqqlh9bthyb.fsf@gitster.mtv.corp.google.com>

mark_tree_uninteresting dereferences a tree pointer before checking if the pointer is valid. Fix that by doing the check first.

Signed-off-by: Stefan Naewe <stefan.naewe@gmail.com>
---
 revision.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/revision.c b/revision.c
index 0fbb684..8c569cc 100644
--- a/revision.c
+++ b/revision.c
@@ -135,10 +135,12 @@ static void mark_tree_contents_uninteresting(struct tree *tree)
 
 void mark_tree_uninteresting(struct tree *tree)
 {
-	struct object *obj = &tree->object;
+	struct object *obj;
 
 	if (!tree)
 		return;
+
+	obj = &tree->object;
 	if (obj->flags & UNINTERESTING)
 		return;
 	obj->flags |= UNINTERESTING;
-- 
2.6.3
Previous: Jeff KingNext: Junio C Hamano
Message 8 of 10 in “revision.c: fix possible null pointer access”
  1. revision.c: fix possible null pointer accessStefan Naewe, Dec 3, 2015
  2. Junio C HamanoDec 3, 2015
  3. Stefan NaeweDec 3, 2015
  4. Philip OakleyDec 3, 2015
  5. Stefan BellerDec 3, 2015
  6. Junio C HamanoDec 4, 2015
  7. Jeff KingDec 4, 2015
  8. revision.c: fix possible null pointer accessStefan Naewe, Dec 5, 2015
  9. Junio C HamanoDec 7, 2015
  10. Johannes SixtDec 7, 2015

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.