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

[PATCH v3 3/5] ref-filter: initialize eaten variable

From
Olga Telezhnaya <olyatelezhnaya@gmail.com>
Date
Jul 17, 2018, 08:22 UTC
Message-ID
<01020164a755d3de-ac85c59f-6a13-4601-b529-9957d9e8b05f-000000@eu-west-1.amazonses.com>
In-Reply-To
<01020164a755d376-b1b86aec-5d26-4d6c-8f8f-2adbb6a8ed65-000000@eu-west-1.amazonses.com>

Initialize variable `eaten` before its using. We may initialize it in parse_object_buffer(), but there are cases when we do not reach this invocation.

Signed-off-by: Olga Telezhnaia <olyatelezhnaya@gmail.com>
---
 ref-filter.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/ref-filter.c b/ref-filter.c
index 27733ef013bed..8db7ca95b12c0 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -1439,7 +1439,8 @@ static const char *get_refname(struct used_atom *atom, struct ref_array_item *re
 static int get_object(struct ref_array_item *ref, const struct object_id *oid,
 		       int deref, struct object **obj, struct strbuf *err)
 {
-	int eaten;
+	/* parse_object_buffer() will set eaten to 0 if free() will be needed */
+	int eaten = 1;
 	int ret = 0;
 	unsigned long size;
 	void *buf = get_obj(oid, obj, &size, &eaten);

--
https://github.com/git/git/pull/520
Previous: Olga TelezhnayaNext: Olga Telezhnaya
Message 2 of 5 in “ref-filter: add info_source to valid_atom”
  1. 1/5 ref-filter: add info_source to valid_atomOlga Telezhnaya, Jul 17, 2018
  2. 3/5 ref-filter: initialize eaten variableOlga Telezhnaya, Jul 17, 2018
  3. 2/5 ref-filter: fill empty fields with empty valuesOlga Telezhnaya, Jul 17, 2018
  4. 5/5 ref-filter: use oid_object_info() to get objectOlga Telezhnaya, Jul 17, 2018
  5. 4/5 ref-filter: merge get_obj and get_objectOlga Telezhnaya, Jul 17, 2018

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.