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

[PATCH 3/4] line-log: initialize diff queue in process_ranges_ordinary_commit()

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Aug 24, 2025, 19:06 UTC
Message-ID
<20250824190644.2573279-4-szeder.dev@gmail.com>
In-Reply-To
<20250824190644.2573279-1-szeder.dev@gmail.com>

process_ranges_ordinary_commit() uses a local diff queue variable, which it leaves uninitialized before passing its address to queue_diffs(). This is not an issue, because at the end of that function the contents of an other diff queue is moved into it by simply overwriting whatever is in there, i.e. without reading any uninitialized memory.

Still, seeing the uninitialized diff queue being passed around scared me more than once, so out of caution let's make sure that it's initialized.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
---
 line-log.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/line-log.c b/line-log.c
index b2a31ae956..71fa857ee8 100644
--- a/line-log.c
+++ b/line-log.c
@@ -1182,7 +1182,7 @@ static int process_ranges_ordinary_commit(struct rev_info *rev, struct commit *c
 					  struct line_log_data *range)
 {
 	struct commit *parent = NULL;
-	struct diff_queue_struct queue;
+	struct diff_queue_struct queue = DIFF_QUEUE_INIT;
 	struct line_log_data *parent_range;
 	int changed;
 
-- 
2.51.0.433.g1a66b3fb12
Previous: SZEDER GáborNext: SZEDER Gábor
Message 7 of 12 in “line-log: optimize merge commit processing”
  1. 0/4 line-log: optimize merge commit processingSZEDER Gábor, Aug 24, 2025
  2. 1/4 line-log: avoid unnecessary tree diffs when processing merge commitsSZEDER Gábor, Aug 24, 2025
  3. Derrick StoleeAug 25, 2025
  4. Junio C HamanoAug 25, 2025
  5. SZEDER GáborAug 28, 2025
  6. 2/4 line-log: get rid of the parents array in process_ranges_merge_commit()SZEDER Gábor, Aug 24, 2025
  7. 3/4 line-log: initialize diff queue in process_ranges_ordinary_commit()SZEDER Gábor, Aug 24, 2025
  8. 4/4 line-log: simplify condition checking for merge commitsSZEDER Gábor, Aug 24, 2025
  9. Junio C HamanoAug 25, 2025
  10. Derrick StoleeAug 25, 2025
  11. Junio C HamanoAug 25, 2025
  12. Derrick StoleeAug 25, 2025

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.