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

[PATCH] diff --no-index: don't leak buffers in queue_diff

From
Bobby Powers <bobbypowers@gmail.com>
Date
May 16, 2012, 14:50 UTC
Message-ID
<1337179831-23461-1-git-send-email-bobbypowers@gmail.com>

queue_diff uses two strbufs, and at the end of the function strbuf_reset was called. This only reset the length of the buffer - any allocated memory was leaked. Using strbuf_release fixes this.

Signed-off-by: Bobby Powers <bobbypowers@gmail.com>
---
 diff-no-index.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/diff-no-index.c b/diff-no-index.c
index 3080b66..f0b0010 100644
--- a/diff-no-index.c
+++ b/diff-no-index.c
@@ -123,8 +123,8 @@ static int queue_diff(struct diff_options *o,
 		}
 		string_list_clear(&p1, 0);
 		string_list_clear(&p2, 0);
-		strbuf_reset(&buffer1);
-		strbuf_reset(&buffer2);
+		strbuf_release(&buffer1);
+		strbuf_release(&buffer2);
 
 		return ret;
 	} else {
-- 
1.7.10.2.521.g8ddb639
Message 1 of 1 in “diff --no-index: don't leak buffers in queue_diff”
  1. diff --no-index: don't leak buffers in queue_diffBobby Powers, May 16, 2012

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.