[FFmpeg-devel] [PATCH] avcodec/bitstream: use av_assert0 in GET_DATA

Paul B Mahol onemda at gmail.com
Wed Dec 9 12:24:08 EET 2020


LGTM

On Tue, Dec 8, 2020 at 11:41 PM Marvin Scholz <epirat07 at gmail.com> wrote:

> For builds with asserts disabled, if the default case would ever be
> reached it could lead to uninitialized use of variables as v is never
> assigned to anything.
>
> This caused the following clang warning:
>
>   libavcodec/bitstream.c:374:5: warning: variable 'len' is used
>   uninitialized whenever switch default is taken
>         [-Wsometimes-uninitialized]
>       COPY(len && len <= nb_bits);
>       ^~~~~~~~~~~~~~~~~~~~~~~~~~~
>   libavcodec/bitstream.c:343:9: note: expanded from macro 'COPY'
>           GET_DATA(len, bits, i, bits_wrap, bits_size);
>   […]
>
> To prevent the uninitialized use, use av_assert0 which aborts when
> assertions are disabled.
> ---
>  libavcodec/bitstream.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/bitstream.c b/libavcodec/bitstream.c
> index 7570fb2204..875e9302f3 100644
> --- a/libavcodec/bitstream.c
> +++ b/libavcodec/bitstream.c
> @@ -107,7 +107,7 @@ void ff_copy_bits(PutBitContext *pb, const uint8_t
> *src, int length)
>          v = *(const uint32_t *)ptr;                         \
>          break;                                              \
>      default:                                                \
> -        av_assert1(0);                                      \
> +        av_assert0(0);                                      \
>      }                                                       \
>  }
>
> --
> 2.24.3 (Apple Git-128)
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-devel mailing list