git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Denton Liu <liu.denton@gmail.com>
To: Git Mailing List <git@vger.kernel.org>
Subject: [PATCH 3/3] range-diff: clear `other_arg` at end of function
Date: Fri, 6 Dec 2019 12:16:31 -0800	[thread overview]
Message-ID: <a2bb9b74184a1c09b416d70c14945e336f6e717f.1575663345.git.liu.denton@gmail.com> (raw)
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


      parent reply	other threads:[~2019-12-06 20:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-06 20:16 [PATCH 0/3] cleanup for 'dl/range-diff-with-notes' Denton Liu
2019-12-06 20:16 ` [PATCH 1/3] t3206: fix incorrect test name Denton Liu
2019-12-06 20:16 ` [PATCH 2/3] range-diff: mark pointers as const Denton Liu
2019-12-06 20:16 ` Denton Liu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a2bb9b74184a1c09b416d70c14945e336f6e717f.1575663345.git.liu.denton@gmail.com \
    --to=liu.denton@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).