[PATCH ustream] ustream-openssl: fix bio memory leak
Eneas U de Queiroz
cotequeiroz at gmail.com
Wed Dec 9 13:07:37 EST 2020
On Wed, Dec 9, 2020 at 1:58 PM Daniel Golle <daniel at makrotopia.org> wrote:
>
> On Wed, Dec 09, 2020 at 05:44:48PM +0100, Petr Štetiar wrote:
> > Eneas U de Queiroz <cotequeiroz at gmail.com> [2020-12-09 13:06:45]:
> >
> > Hi,
> >
> > > Using the patch by Pan Chen as inspiration, this avoids a memory leak by
> > > using a global BIO_METHOD pointer that doesn't ordinarily need to be
> > > freed.
> >
> > this sounds weird, how is global pointer avoiding memory leaks? :-)
>
> Well, it moves it from "definitely lost" to "still reachable" when
> looking at it with valgrind. We will still have to free it as well,
> and that could be done just like in the original patch.
>
See my reply to Petr. I'm not sure if valgrind will be completely
pleased with my approach. I'm not an expert with valgrind, but it
seems to not like that I left it in the heap to be cleaned up by the
process end, but that is my intention. As long as I am not allocating
memory again--it will only be created when methods_ustream is NULL,
which is when it is initialized, and there's nowhere else in code that
touches it. Note the const in the definition of: BIO * BIO_new(const
BIO_METHOD *type);
Cheers,
Eneas
More information about the openwrt-devel
mailing list