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

[PATCH] Fix memory leak in apply_filter.

From
Pierre Habouzit <madcoder@debian.org>
Date
Oct 5, 2007, 08:29 UTC
Message-ID
<20071005082925.GG19879@artemis.corp>
In-Reply-To
<20071005082026.GE19879@artemis.corp>
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
---

While we're at it... Here is a stupid memory leak in apply_filter. On top of the previous commit.

The same, repost, unsigned doh.
 convert.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/convert.c b/convert.c
index 4664197..d5c197f 100644
--- a/convert.c
+++ b/convert.c
@@ -293,10 +293,9 @@ static int apply_filter(const char *path, const char *src, size_t len,
 	}
 
 	if (ret) {
-		*dst = nbuf;
-	} else {
-		strbuf_release(&nbuf);
+		strbuf_swap(dst, &nbuf);
 	}
+	strbuf_release(&nbuf);
 	return ret;
 }
 
-- 
1.5.3.4.208.gdcc67-dirty
Previous: Pierre HabouzitNext: Johannes Schindelin
Message 16 of 18 in “Fix in-place editing in crlf_to_git and ident_to_git.”
  1. Fix in-place editing in crlf_to_git and ident_to_git.Pierre Habouzit, Oct 5, 2007
  2. Fix in-place editing functions in convert.cPierre Habouzit, Oct 5, 2007
  3. Johannes SixtOct 5, 2007
  4. Bernt HansenOct 5, 2007
  5. Linus TorvaldsOct 5, 2007
  6. Pierre HabouzitOct 5, 2007
  7. Sam RavnborgOct 5, 2007
  8. Pierre HabouzitOct 5, 2007
  9. Sam RavnborgOct 5, 2007
  10. Linus TorvaldsOct 5, 2007
  11. Sam RavnborgOct 5, 2007
  12. Linus TorvaldsOct 5, 2007
  13. Dmitry PotapovOct 5, 2007
  14. Linus TorvaldsOct 5, 2007
  15. Fix memory leak in apply_filter.Pierre Habouzit, Oct 5, 2007
  16. Fix memory leak in apply_filter.Pierre Habouzit, Oct 5, 2007
  17. Johannes SchindelinOct 5, 2007
  18. Pierre HabouzitOct 5, 2007

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.