Ok, thanks for the suggestion. There's currently only one path to get at the free(tmpStats), but for safety I'll change it.
Robbert > -----Oorspronkelijk bericht----- > Van: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > Burton M. Strauss III > Verzonden: donderdag 24 juni 2004 15:06 > Aan: [EMAIL PROTECTED] > Onderwerp: RE: [Ntop-dev] [PATCH] Fix memory leak in RRDplugin > domainstats > > > Just as a general rule, code those as > > if(xxx != NULL) free(xxx); > > That way, whatever path it takes to get there is safe. > > -----Burton > > > -----Original Message----- > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > > Behalf Of Kouprie, Robbert > > Sent: Thursday, June 24, 2004 7:27 AM > > To: [EMAIL PROTECTED] > > Cc: [EMAIL PROTECTED] > > Subject: [Ntop-dev] [PATCH] Fix memory leak in RRDplugin domainstats > > > > > > Hi, > > > > In my last patch to introduce graceful handling of OOM in > > RRDplugin's domainstats routine, I introduced a possible memory > > leak. The only situation in which this would occur is when the > > box was OOM anyway, but that shouldn't keep ntop from freeing > > unused memory. > > > > Robbert > > > > --- ntop/plugins/rrdPlugin.c.orig 2004-06-24 > > 14:11:09.902811680 +0200 > > +++ ntop/plugins/rrdPlugin.c 2004-06-24 14:15:06.339867784 +0200 > > @@ -1874,7 +1874,9 @@ > > stats = (DomainStats**)mallocAndInitWithReportWarn(len, > > "rrdMainLoop(2)"); > > > > if (stats == NULL) { > > - traceEvent(CONST_TRACE_WARNING, "RRD: Out of memory, > > skipping domain RRD dumps"); > > + traceEvent(CONST_TRACE_WARNING, "RRD: Out of memory, > > skipping domain RRD dumps"); > > + /* before continuing, also free the block of memory > > allocated a few lines up */ > > + free(tmpStats); > > continue; > > } > > > > > _______________________________________________ > Ntop-dev mailing list > [EMAIL PROTECTED] > http://listgateway.unipi.it/mailman/listinfo/ntop-dev > _______________________________________________ Ntop-dev mailing list [EMAIL PROTECTED] http://listgateway.unipi.it/mailman/listinfo/ntop-dev
