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

[PATCH] fix memory leak in parse_object when check_sha1_signature fails

From
CRCarlos Rica <jasampler@gmail.com>
Date
May 25, 2007, 01:46 UTC
Message-ID
<1b46aba20705241846u615785eeh7c3ebeaf840b2180@mail.gmail.com>

When check_sha1_signature fails, program is not terminated: it prints an error message and returns NULL, so the buffer returned by read_sha1_file should be freed before.

Signed-off-by: Carlos Rica <jasampler@gmail.com>
---
 object.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/object.c b/object.c
index 78a44a6..ccd7dd7 100644
--- a/object.c
+++ b/object.c
@@ -185,6 +185,7 @@ struct object *parse_object(const unsigned char *sha1)
 	if (buffer) {
 		struct object *obj;
 		if (check_sha1_signature(sha1, buffer, size, typename(type)) < 0) {
+			free(buffer);
 			error("sha1 mismatch %s\n", sha1_to_hex(sha1));
 			return NULL;
 		}
-- 
1.5.0
Next: Shawn O. Pearce
Message 1 of 3 in “fix memory leak in parse_object when check_sha1_signature fails”
  1. fix memory leak in parse_object when check_sha1_signature failsCarlos Rica, May 25, 2007
  2. Shawn O. PearceMay 25, 2007
  3. Junio C HamanoMay 25, 2007

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.