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

[PATCH 3/3] range-diff: clear `other_arg` at end of function

From
Denton Liu <liu.denton@gmail.com>
Date
Dec 6, 2019, 20:16 UTC
Message-ID
<a2bb9b74184a1c09b416d70c14945e336f6e717f.1575663345.git.liu.denton@gmail.com>
In-Reply-To
<cover.1575663345.git.liu.denton@gmail.com>

We were leaking memory by not clearing `other_arg` after we were done using it. Clear it after we've finished using it.

Note that this isn't strictly necessary since the memory will be reclaimed once the command exits. However, since we are releasing the strbufs, we should also clear `other_arg` for consistency.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
 builtin/range-diff.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/builtin/range-diff.c b/builtin/range-diff.c
index 98acf3533e..d8a4670629 100644
--- a/builtin/range-diff.c
+++ b/builtin/range-diff.c
@@ -84,6 +84,7 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
 	res = show_range_diff(range1.buf, range2.buf, creation_factor,
 			      simple_color < 1, &diffopt, &other_arg);
 
+	argv_array_clear(&other_arg);
 	strbuf_release(&range1);
 	strbuf_release(&range2);
 
-- 
2.24.0.612.g9b7bad38f5
Previous: Denton Liu
Message 4 of 4 in “cleanup for 'dl/range-diff-with-notes'”
  1. 0/3 cleanup for 'dl/range-diff-with-notes'Denton Liu, Dec 6, 2019
  2. 1/3 t3206: fix incorrect test nameDenton Liu, Dec 6, 2019
  3. 2/3 range-diff: mark pointers as constDenton Liu, Dec 6, 2019
  4. 3/3 range-diff: clear `other_arg` at end of functionDenton Liu, Dec 6, 2019

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.