Web lists-archives.com

Re: [MPlayer-dev-eng] [PATCH][Trac 2311] codec_path mem leak




On 2017-03-07 21:26 +0100, Reimar Döffinger wrote:
> On Fri, Jan 13, 2017 at 10:14:43PM +0100, Alexander Strasser wrote:
> > Hello all,
> > 
> > while investigating the leaks pointed out in ticket #2311, I found
> > that the attached patch fixes the remaining leak.
> > 
> > The current code seems pretty wrong. At least, as I understand it,
> > the function set_codec_path ever only got called once. The implementation
> > combined with exporting the codec_path global var seems not solid at all.
> > 
> > Still I feel like I am missing something...
> 
> Same feeling here, but I'd say go for it.


Committed.


If my source archaeology is not mistaken, the set_codec_path function
initially came from the avifile project in 2002.

The -codecpath option itself came much later in 2010, though the variables
were separated; there was codec_path and def_path. More importantly codec_path
used to be initialized to NULL, which fits the design of set_codec_path.

So this leak itself must have came in, when the codec_path variable
was initialized to a default path (from a literal), which was copied into a
malloc'd buffer by the config system, and then was again copied into a
maclloc'd buffer by the set_codec_path function. Made worse by using only
codec_path and no def_path anymore.

The latter makes it a clear leak, because the second alloc+copy will
overwrite the pointer to the buffer allocated by the config system.


  Alexander
_______________________________________________
MPlayer-dev-eng mailing list
MPlayer-dev-eng@xxxxxxxxxxxx
https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng