git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Taylor Blau <me@ttaylorr.com>,
	Eric Sunshine <sunshine@sunshineco.com>,
	Jeff King <peff@peff.net>,
	Johannes Schindelin <johannes.schindelin@gmx.de>,
	Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: [PATCH v2 1/6] range-diff: avoid leaking memory in two error code paths
Date: Fri, 05 Feb 2021 14:46:08 +0000	[thread overview]
Message-ID: <15f4f6abdaa206ca9b89f4f2444b88a77ef1060c.1612536373.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.869.v2.git.1612536373.gitgitgadget@gmail.com>

From: Johannes Schindelin <johannes.schindelin@gmx.de>

In the code paths in question, we already release a lot of memory, but
the `current_filename` variable was missed. Fix that.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 range-diff.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/range-diff.c b/range-diff.c
index 7a38dc871543..9972808fe4cf 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -98,6 +98,7 @@ static int read_patches(const char *range, struct string_list *list,
 			if (get_oid(p, &util->oid)) {
 				error(_("could not parse commit '%s'"), p);
 				free(util);
+				free(current_filename);
 				string_list_clear(list, 1);
 				strbuf_release(&buf);
 				strbuf_release(&contents);
@@ -113,6 +114,7 @@ static int read_patches(const char *range, struct string_list *list,
 			error(_("could not parse first line of `log` output: "
 				"did not start with 'commit ': '%s'"),
 			      line);
+			free(current_filename);
 			string_list_clear(list, 1);
 			strbuf_release(&buf);
 			strbuf_release(&contents);
-- 
gitgitgadget


  reply	other threads:[~2021-02-05 22:08 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-04 20:07 [PATCH 0/6] Optionally restrict range-diff output to "left" or "right" range only Johannes Schindelin via GitGitGadget
2021-02-04 20:07 ` [PATCH 1/6] range-diff: avoid leaking memory in two error code paths Johannes Schindelin via GitGitGadget
2021-02-04 20:07 ` [PATCH 2/6] range-diff: libify the read_patches() function again Johannes Schindelin via GitGitGadget
2021-02-04 20:07 ` [PATCH 3/6] range-diff: simplify code spawning `git log` Johannes Schindelin via GitGitGadget
2021-02-04 20:07 ` [PATCH 4/6] range-diff: combine all options in a single data structure Johannes Schindelin via GitGitGadget
2021-02-04 23:56   ` Eric Sunshine
2021-02-05 14:13     ` Johannes Schindelin
2021-02-04 20:07 ` [PATCH 5/6] range-diff: move the diffopt initialization down one layer Johannes Schindelin via GitGitGadget
2021-02-04 20:07 ` [PATCH 6/6] range-diff: offer --left-only/--right-only options Johannes Schindelin via GitGitGadget
2021-02-04 22:41 ` [PATCH 0/6] Optionally restrict range-diff output to "left" or "right" range only Junio C Hamano
2021-02-04 22:48   ` Taylor Blau
2021-02-05  0:56     ` Junio C Hamano
2021-02-05 10:11       ` Jeff King
2021-02-08 22:36         ` Johannes Schindelin
2021-02-05 20:05       ` Taylor Blau
2021-02-05 14:46 ` [PATCH v2 " Johannes Schindelin via GitGitGadget
2021-02-05 14:46   ` Johannes Schindelin via GitGitGadget [this message]
2021-02-05 14:46   ` [PATCH v2 2/6] range-diff: libify the read_patches() function again Johannes Schindelin via GitGitGadget
2021-02-05 14:46   ` [PATCH v2 3/6] range-diff: simplify code spawning `git log` Johannes Schindelin via GitGitGadget
2021-02-05 14:46   ` [PATCH v2 4/6] range-diff: combine all options in a single data structure Johannes Schindelin via GitGitGadget
2021-02-05 14:46   ` [PATCH v2 5/6] range-diff: move the diffopt initialization down one layer Johannes Schindelin via GitGitGadget
2021-02-05 14:46   ` [PATCH v2 6/6] range-diff: offer --left-only/--right-only options Johannes Schindelin via GitGitGadget

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

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

  git send-email \
    --in-reply-to=15f4f6abdaa206ca9b89f4f2444b88a77ef1060c.1612536373.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=johannes.schindelin@gmx.de \
    --cc=me@ttaylorr.com \
    --cc=peff@peff.net \
    --cc=sunshine@sunshineco.com \
    /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.
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 NNTP newsgroup(s).