[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[leafnode-list] Re: applyfilter failure malloc(16384) failed: Space for article



Paul Brooks schrieb am 2010-12-14:

> 
> I'm running leafnode-2.0.0.alpha20081229a, using applyfilter I came across this error
> malloc(16384) failed: Space for article

Hi Paul,

sorry for the trouble, and congratulations on finding a memory leak!

The attached patch should fix that problem.  Apply it to your leafnode
source, then recompile and reinstall and let me know if it solves the
problem.  It does for me.  (Thanks to valgrind it was very easy to
find the culprit.)

Hope that helps & best regards
Matthias
commit ab4f1f7f8d2a143a452c0596e2c92d2df224be01
Author: Matthias Andree <matthias.andree@xxxxxx>
Date:   Wed Dec 15 13:35:45 2010 +0100

    Plug memory leak in applyfilter().
    
    Reported 2010-12-14 by Paul Brooks through the mailing list.
    Analyzed with valgrind.

diff --git a/applyfilter.c b/applyfilter.c
index 3191cda..bfacaca 100644
--- a/applyfilter.c
+++ b/applyfilter.c
@@ -71,14 +71,12 @@ static int applyfilter(const char *name, struct newsgroup *g,
 	unsigned long *kept, unsigned long *deleted)
 {
     static size_t lsize = MAXHEADERSIZE + 1;
-    static char *l;
+    char *l;
     struct stat st;
     int score, fd;
     struct utimbuf u;
     unsigned long n;
 
-    l = (char *)critmalloc(lsize, "Space for article");
-
     if (stat(name, &st)) {
 	ln_log(LNLOG_SNOTICE, LNLOG_CARTICLE,
 		"cannot stat file \"%s\" in newsgroup %s: %m",
@@ -97,6 +95,8 @@ static int applyfilter(const char *name, struct newsgroup *g,
 	return 0;
     }
 
+    l = (char *)critmalloc(lsize, "Space for article");
+
     if((fd = open(name, O_RDONLY)) >= 0)
     {
 	int ret;
@@ -167,6 +167,9 @@ static int applyfilter(const char *name, struct newsgroup *g,
 	ln_log(LNLOG_SERR, LNLOG_CARTICLE,
 		"could not open file \"%s\" in newsgroup %s\n",
 		name, g->name);
+
+    free(l);
+
     return 0;
 }
 

Attachment: pgpIa9ueqAWtb.pgp
Description: PGP signature

-- 
_______________________________________________
leafnode-list mailing list
leafnode-list@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
https://www.dt.e-technik.uni-dortmund.de/mailman/listinfo/leafnode-list
http://leafnode.sourceforge.net/