[PATCH] D105169: [Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default

Martin Storsjö via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 18 00:56:49 PDT 2021


mstorsjo added a comment.

In D105169#3069220 <https://reviews.llvm.org/D105169#3069220>, @aqjune wrote:

> It seems the original code has a use of an uninitialized variable.
> Line 4420 at seek-preproc.c (function `ff_seek_frame_binary`):
>
>    int64_t pos_min=pos_min, pos_max=pos_max, pos, pos_limit; // pos_min and pos_max are self-assigned.
>   ...
>   if (sti->index_entries) {
>      ...
>   }
>   // pos_min and pos_max are used as arguments below
>   pos = ff_gen_search(s, stream_index, target_ts, pos_min, pos_max, pos_limit,
>                        ts_min, ts_max, flags, &ts, avif->read_timestamp);
>
> https://gist.github.com/aqjune/3bd0ea19bbc12b4744843c0c070e994c
>
> If the branch is not taken, `pos_min` and `pos_max` are read while they are still uninitialized.
>
> I guess the variables are self-assigned to avoid warnings?

Yes, I believe so. If the branch is not taken, `pos_min` and `pos_max` are undefined when entering `ff_gen_search`. (I would assume that their value isn't ever used within `ff_gen_search` in that case.) But regardless of that, in this case, the generated code crashes around this line, https://gist.github.com/aqjune/3bd0ea19bbc12b4744843c0c070e994c#file-ff_seek_frame_binary-c-L39, before entering `ff_gen_search` - and within that branch, those variables are properly set before they're used.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105169/new/

https://reviews.llvm.org/D105169



More information about the cfe-commits mailing list