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

[PATCH] parse_object: check if buffer is non-NULL before freeing it

From
Jonas Fonseca <fonseca@diku.dk>
Date
Aug 28, 2006, 00:31 UTC
Message-ID
<20060828003129.GE20904@diku.dk>

Two code paths may cause this and other places in the source have the courtesy to do the check.

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
 object.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/object.c b/object.c
index 9281300..c08347f 100644
--- a/object.c
+++ b/object.c
@@ -173,7 +173,8 @@ struct object *parse_object(const unsign
 		} else {
 			obj = NULL;
 		}
-		free(buffer);
+		if (buffer)
+			free(buffer);
 		return obj;
 	}
 	return NULL;
-- 
1.4.2.g2f76-dirty

-- 
Jonas Fonseca
Next: Junio C Hamano
Message 1 of 4 in “parse_object: check if buffer is non-NULL before freeing it”
  1. parse_object: check if buffer is non-NULL before freeing itJonas Fonseca, Aug 28, 2006
  2. Junio C HamanoAug 28, 2006
  3. Linus TorvaldsAug 28, 2006
  4. Junio C HamanoAug 28, 2006

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.