[FFmpeg-devel] [PATCH 2/3] avfilter/signature_lookup: Initialize bestmatch
Michael Niedermayer
michael at niedermayer.cc
Mon Apr 22 05:09:37 EEST 2024
On Mon, Apr 22, 2024 at 01:10:47AM +0200, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Fixes: CID1500345 Uninitialized scalar variable
> >
> > Sponsored-by: Sovereign Tech Fund
> > Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> > ---
> > libavfilter/signature_lookup.c | 4 +---
> > 1 file changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/libavfilter/signature_lookup.c b/libavfilter/signature_lookup.c
> > index a3086b38cca..dc0a2ef2b24 100644
> > --- a/libavfilter/signature_lookup.c
> > +++ b/libavfilter/signature_lookup.c
> > @@ -535,16 +535,14 @@ static MatchingInfo lookup_signatures(AVFilterContext *ctx, SignatureContext *sc
> > {
> > CoarseSignature *cs, *cs2;
> > MatchingInfo *infos;
> > - MatchingInfo bestmatch;
> > + MatchingInfo bestmatch = {0};
> > MatchingInfo *i;
> >
> > cs = first->coarsesiglist;
> > cs2 = second->coarsesiglist;
> >
> > /* score of bestmatch is 0, if no match is found */
> > - bestmatch.score = 0;
> > bestmatch.meandist = 99999;
> > - bestmatch.whole = 0;
> >
> > fill_l1distlut(sc->l1distlut);
> >
>
> Does this fix an actual bug or just suppress a Coverity warning?
returning partially initialized structs is IMHO bad practice
it is strictly not a bug i guess.
But its similar to not initializing pointers to NULL and then
having to track if all paths initialize them before freeing.
This is similar. With passing partially initialized structs around,
one would have to ensure that nothing is touched that isnt initialized.
Ive marked the issue as false positive now as that is in fact more
correct.
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20240422/1aaf8d13/attachment.sig>
More information about the ffmpeg-devel
mailing list