Opened 4 years ago

Closed 4 years ago

#4514 closed defect (fixed)

webmdashenc may return an uninitialized variable

Reported by: jeremyhu Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: regression
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

As observed in:

http://fate.ffmpeg.org/log.cgi?time=20150426121301&log=compile&slot=x86_64-darwin-clang-3.7

/Users/jeremy/src/ffmpeg/fate/x86_64-darwin-clang-3.7/src/libavformat/utils.c:1818:9: warning: variable 'pos_min' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
    if (st->index_entries) {
        ^~~~~~~~~~~~~~~~~
/Users/jeremy/src/ffmpeg/fate/x86_64-darwin-clang-3.7/src/libavformat/utils.c:1851:53: note: uninitialized use occurs here
    pos = ff_gen_search(s, stream_index, target_ts, pos_min, pos_max, pos_limit,
                                                    ^~~~~~~
/Users/jeremy/src/ffmpeg/fate/x86_64-darwin-clang-3.7/src/libavformat/utils.c:1818:5: note: remove the 'if' if its condition is always true
    if (st->index_entries) {
    ^~~~~~~~~~~~~~~~~~~~~~~
/Users/jeremy/src/ffmpeg/fate/x86_64-darwin-clang-3.7/src/libavformat/utils.c:1802:5: note: variable 'pos_min' is declared here
    int64_t av_uninit(pos_min), av_uninit(pos_max), pos, pos_limit;
    ^
/Users/jeremy/src/ffmpeg/fate/x86_64-darwin-clang-3.7/src/libavformat/utils.c:1840:13: warning: variable 'pos_max' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
        if (index >= 0) {
            ^~~~~~~~~~
/Users/jeremy/src/ffmpeg/fate/x86_64-darwin-clang-3.7/src/libavformat/utils.c:1851:62: note: uninitialized use occurs here
    pos = ff_gen_search(s, stream_index, target_ts, pos_min, pos_max, pos_limit,
                                                             ^~~~~~~
/Users/jeremy/src/ffmpeg/fate/x86_64-darwin-clang-3.7/src/libavformat/utils.c:1840:9: note: remove the 'if' if its condition is always true
        if (index >= 0) {
        ^~~~~~~~~~~~~~~~
/Users/jeremy/src/ffmpeg/fate/x86_64-darwin-clang-3.7/src/libavformat/utils.c:1818:9: warning: variable 'pos_max' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
    if (st->index_entries) {
        ^~~~~~~~~~~~~~~~~
/Users/jeremy/src/ffmpeg/fate/x86_64-darwin-clang-3.7/src/libavformat/utils.c:1851:62: note: uninitialized use occurs here
    pos = ff_gen_search(s, stream_index, target_ts, pos_min, pos_max, pos_limit,
                                                             ^~~~~~~
/Users/jeremy/src/ffmpeg/fate/x86_64-darwin-clang-3.7/src/libavformat/utils.c:1818:5: note: remove the 'if' if its condition is always true
    if (st->index_entries) {
    ^~~~~~~~~~~~~~~~~~~~~~~
/Users/jeremy/src/ffmpeg/fate/x86_64-darwin-clang-3.7/src/libavformat/utils.c:1802:5: note: variable 'pos_max' is declared here
    int64_t av_uninit(pos_min), av_uninit(pos_max), pos, pos_limit;
    ^
/Users/jeremy/src/ffmpeg/fate/x86_64-darwin-clang-3.7/src/libavformat/webmdashenc.c:392:17: warning: variable 'ret' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized]
            if (!filename ||
                ^~~~~~~~~
/Users/jeremy/src/ffmpeg/fate/x86_64-darwin-clang-3.7/src/libavformat/webmdashenc.c:394:24: note: uninitialized use occurs here
                return ret;
                       ^~~
/Users/jeremy/src/ffmpeg/fate/x86_64-darwin-clang-3.7/src/libavformat/webmdashenc.c:392:17: note: remove the '||' if its condition is always false
            if (!filename ||
                ^~~~~~~~~~~~
/Users/jeremy/src/ffmpeg/fate/x86_64-darwin-clang-3.7/src/libavformat/webmdashenc.c:388:16: note: initialize the variable 'ret' to silence this warning
        int ret;
               ^
                = 0

Change History (4)

comment:1 Changed 4 years ago by jeremyhu

  • Version changed from unspecified to git-master

comment:2 Changed 4 years ago by heleppkes

The first three are false-positives. The av_uninit is supposed to suppress this, which apparently works with GCC. Should teach your clang about it. :)

comment:3 Changed 4 years ago by cehoyos

  • Keywords regression added
  • Reproduced by developer set
  • Status changed from new to open
  • Summary changed from libavformat has a few cases where it will reference uninitialized variables to webmdashenc may return an uninitialized variable

The warning in webmdashenc.c is a regression since 1c37848f9029985d1271da9a0d161c2ebf0aca81

comment:4 Changed 4 years ago by cehoyos

  • Resolution set to fixed
  • Status changed from open to closed
Note: See TracTickets for help on using tickets.