[MPlayer-dev-eng] [RFC] always memset structs to 0 in libass

Grigori Goronzy greg at chown.ath.cx
Sat Mar 28 20:12:08 CET 2009


Reimar Döffinger wrote:
> Hello,
> I originally stumbled over this because of valgrind warnings.
> The real issue is that you can't just use the default
> hashmap_hash/hashmap_key_compare with structs, but I leave that to the
> libass maintainer(s).
>

Yes. The issue is that the compiler is allowed to create code that
modifies the padding introduced by alignment. In the worst case this can
lead to massive memory leaks, because the hash keys never match.

There are two possible workarounds:
a) packed structs (bad idea, nonstandard and compiler dependent)
b) compare the structs field by field

Uoti's repo includes a fix for this problem which is using b).

About the patch -- looks fine in my opinion.

Grigori



More information about the MPlayer-dev-eng mailing list