Opened 10 years ago

Closed 9 years ago

#4514 closed defect (fixed)

webmdashenc may return an uninitialized variable

Reported by: Jeremy Huddleston 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 by Jeremy Huddleston, 10 years ago

Version: unspecifiedgit-master

comment:2 by Hendrik, 10 years ago

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 by Carl Eugen Hoyos, 10 years ago

Keywords: regression added
Reproduced by developer: set
Status: newopen
Summary: libavformat has a few cases where it will reference uninitialized variableswebmdashenc may return an uninitialized variable

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

comment:4 by Carl Eugen Hoyos, 9 years ago

Resolution: fixed
Status: openclosed
Note: See TracTickets for help on using tickets.