[FFmpeg-devel] [PATCH v3 0/3] avformat/hashenc: add streamhash muxer

Moritz Barsnick barsnick at gmx.net
Sun Sep 22 15:28:12 EEST 2019


On Sat, Sep 21, 2019 at 10:07:25 +0530, Gyan wrote:
[...]
> Coverity reports three issues arising from this patchset, actually one
> issue, having an instance in each of the three init () functions.
[...]
>      c->hashes = av_mallocz_array(1, sizeof(c->hashes));
[...]
> "Passing argument "8UL /* sizeof (c->hashes) */" to function
> "av_mallocz_array" and then casting the return value to "struct
> AVHashContext **" is suspicious. In this particular case "sizeof (struct
> AVHashContext **)" happens to be equal to "sizeof (struct AVHashContext
> *)", but this is not a portable assumption."

Now that you point it out, it's obvious. Shame on me, it wasn't before.

(For the record, for those who want to learn what I learned:
    c->hashes = av_mallocz_array(1, sizeof(*c->hashes));
would have been correct.)

Too bad we don't have other static analysis tools to catch this. (Or
would cppcheck have caught this?) I'm aware that Coverity only operates
on the actual repo, not on submitted patches.

Anyway, a patch to fix this is posted.
Thanks,
Moritz


More information about the ffmpeg-devel mailing list