PR #23038 opened by xiaozhuai URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23038 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23038.patch
libavformat/cbs.c includes this file with a different set of CBS_* macros. In configurations using --disable-everything, all coded bitstream types may be disabled for that instance, leaving cbs_type_table empty. This triggers a zero-sized array warning with MSVC and may lead to an internal compiler error with optimization enabled. Add a NULL terminator and iterate until the terminator instead of using FF_ARRAY_ELEMS(). The runtime behavior is unchanged. The code currently permits building an instance of cbs.c with no enabled coded bitstream types. In that case the generated table is empty. Make the table explicitly NULL-terminated so this configuration is valid C for compilers that reject or mishandle empty arrays. Signed-off-by: xiaozhuai <[email protected]> >From f04e3524c81148cf06c5c2df89c0f0a7347e30eb Mon Sep 17 00:00:00 2001 From: xiaozhuai <[email protected]> Date: Wed, 6 May 2026 12:33:13 +0800 Subject: [PATCH] avcodec/cbs: avoid empty type table libavformat/cbs.c includes this file with a different set of CBS_* macros. In configurations using --disable-everything, all coded bitstream types may be disabled for that instance, leaving cbs_type_table empty. This triggers a zero-sized array warning with MSVC and may lead to an internal compiler error with optimization enabled. Add a NULL terminator and iterate until the terminator instead of using FF_ARRAY_ELEMS(). The runtime behavior is unchanged. The code currently permits building an instance of cbs.c with no enabled coded bitstream types. In that case the generated table is empty. Make the table explicitly NULL-terminated so this configuration is valid C for compilers that reject or mishandle empty arrays. Signed-off-by: xiaozhuai <[email protected]> --- libavcodec/cbs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c index 7ff0f89aa5..7357c0f9ac 100644 --- a/libavcodec/cbs.c +++ b/libavcodec/cbs.c @@ -61,6 +61,7 @@ static const CodedBitstreamType *const cbs_type_table[] = { #if CBS_VP9 &CBS_FUNC(type_vp9), #endif + NULL }; const enum AVCodecID CBS_FUNC(all_codec_ids)[] = { @@ -105,7 +106,7 @@ av_cold int CBS_FUNC(init)(CodedBitstreamContext **ctx_ptr, int i; type = NULL; - for (i = 0; i < FF_ARRAY_ELEMS(cbs_type_table); i++) { + for (i = 0; cbs_type_table[i]; i++) { if (cbs_type_table[i]->codec_id == codec_id) { type = cbs_type_table[i]; break; -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
