[Lognorm] Memory Leak in liblognorm?

Rainer Gerhards rgerhards at hq.adiscon.com
Tue Jul 16 17:51:16 CEST 2013


glad it helped -- and sorry for previous briefness ;)

Rainer


On Tue, Jul 16, 2013 at 5:24 PM, Champ Clark III <cclark at quadrantsec.com>wrote:

>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>
> > > believe me, that's the fix ;)
>
> .. Yep :)
>
> > > The key point to understand is that ee_fmtEventToRFC5424 returns a
> *new* estr into the
> result pointer you provide (str in your case). Have a look here, and
> carefully look at line 156, where it is created:
> > >
>
> http://git.adiscon.com/?p=libee.git;a=blob;f=src/syslog_enc.c;h=d559521581242ec73a5687aae1de83ba4f2fbbe3;hb=HEAD#l150
> > > So while you have just one variable, this one variable points to
> different objects at different points in time. So when you assign a new
> object to it (like you do with ee_fmtEventToRFC5424), you need to free
> the previous object, as you otherwise can never do that.
>
> ..snip..
> >
> > > Here, you also supply the same variable to free, but each time it
> points to a different memory block. So no double-free.
>
> Ahhh!  Okay!  Thank you for the explanation,  that really clears it up!
>
> > > You must make sure that you consistently free the pervious object if
> you re-use a variable to
> point to a new object (or alternatively have a single variable for each
> object - one that is not being reused).
> >
> > > As a side-note: things like the almost constant property name I tend
> to store in global variables and only create once and use the same set
> of variables all the time without re-creating them. Depending on what
> you do, this can make some performace diffrence.
> >
>
> Thanks for the tip,  I'll play with it.
>
> Again.. Thank you for the help!  I really appreciate it!
>
>
>
> - --
> - - Quadrant Information Security
>   Champ Clark III
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iQEcBAEBAgAGBQJR5WWsAAoJENnmXt7Lmc3K57cH/jS3nCvg3BeGdvgaZv4RV3PX
> c5Ds71DRaGK0Jjxly3+M+1qWndAjCDcxCYZSnmNZzkuTFnNJ0eDV2pkSAKqo87f4
> vde06oGemOIzAgUZAfSpj3ssXbpL2n8F/KAS3x8DTGwOWybtgSQxWUrM/ds7xtAV
> e0vepSlDjCDmr235OBwbKD4M+TYK2uD/rIGe/AwyyXk5djv8CjNZUZWwzgRha8q/
> aNG3M3CsqnYXn2pZBD1zlXvhFYjp0x9KdqFy11CPY6nXyWAYwG0hXJR2vz9NPUbY
> 7Ax6sa+fqaxg2PkQSs30I4HerGEwipLYEgeDhqaiIanwFwZIw8c8R/rKpkb9++w=
> =AI3L
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> Lognorm mailing list
> Lognorm at lists.adiscon.com
> http://lists.adiscon.net/mailman/listinfo/lognorm
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.adiscon.net/pipermail/lognorm/attachments/20130716/fc2fddc7/attachment.htm>


More information about the Lognorm mailing list