Opened 8 years ago

Closed 7 years ago

Last modified 7 years ago

#5102 closed defect (wontfix)

Variable used uninitialized in libavcodec/ffv1enc.c

Reported by: Jeremy Huddleston Owned by:
Priority: minor Component: avcodec
Version: git-master Keywords: ffv1 ubsan
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

The following were observed when building N-77414-g484cc66 and should probably be fixed:

libavcodec/ffv1enc.c:434:17: warning: variable 'a' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
            if (lbd) {
                ^~~
libavcodec/ffv1enc.c:457:31: note: uninitialized use occurs here
            sample[3][0][x] = a;
                              ^
libavcodec/ffv1enc.c:434:13: note: remove the 'if' if its condition is always true
            if (lbd) {
            ^~~~~~~~~
libavcodec/ffv1enc.c:433:13: note: variable 'a' is declared here
            int b, g, r, av_uninit(a);
            ^

Change History (4)

comment:1 by Carl Eugen Hoyos, 8 years ago

Keywords: ffv1 added
Priority: normalminor
Version: unspecifiedgit-master

The warning was originally addressed in 0b23452c01c5f8145de111f09c0e9a7d5bd82068
When encoding RGB >8 bit, line 453 reads from an uninitialized value:

sample[3][0][x] = a;

sample[3][0][x] will not be used afterwards.
I suspect this is speed-critical code, a possible workaround would be to manually unroll the for (p = 0; p < 3 + s->transparency; p++) { loop in line 455 and move the above assignment in the transparency part of the unrolled loop. This may still incorrectly trigger the warning though.

comment:2 by Carl Eugen Hoyos, 8 years ago

Summary: Variables used uninitialized in libavcodec/ffv1enc.cVariable used uninitialized in libavcodec/ffv1enc.c

comment:3 by Elon Musk, 7 years ago

Resolution: wontfix
Status: newclosed

comment:4 by Carl Eugen Hoyos, 7 years ago

Keywords: ubsan added
Note: See TracTickets for help on using tickets.