Opened 18 months ago

Closed 3 months ago

Last modified 3 months ago

#5102 closed defect (wontfix)

Variable used uninitialized in libavcodec/ffv1enc.c

Reported by: jeremyhu 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 Changed 18 months ago by cehoyos

  • Keywords ffv1 added
  • Priority changed from normal to minor
  • Version changed from unspecified to git-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 Changed 18 months ago by cehoyos

  • Summary changed from Variables used uninitialized in libavcodec/ffv1enc.c to Variable used uninitialized in libavcodec/ffv1enc.c

comment:3 Changed 3 months ago by richardpl

  • Resolution set to wontfix
  • Status changed from new to closed

comment:4 Changed 3 months ago by cehoyos

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