diff mbox series

[FFmpeg-devel,3/4] avcodec/h264_loopfilter: Fix incorrect function parameter array size

Message ID DB6PR0101MB221460FFEB0FF2B318B697738F879@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com
State Accepted
Commit 890efee2b80d5b3b5eb087d1f2a472854f66afe3
Headers show
Series [FFmpeg-devel,1/4] avformat/asfcrypt: Fix wrong array length in function declaration | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt July 11, 2022, 3:05 a.m. UTC
filter_mb_mbaff_edgev() and filter_mb_mbaff_edgecv()
have a function parameter whose expected size depends upon
another parameter: It is 2 * bsi + 1 (with bsi always being 1 or 2).
This array is declared as const int16_t[7], yet some of the callers
with bsi == 1 call it with only an const int16_t[4] available.
This leads to -Wstringop-overread warnings from GCC 12.1.

This commit fixes these by replacing [7] with [/* 2 * bsi + 1 */],
so that the expected range and its dependence on bsi is immediately
visible.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/h264_loopfilter.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/h264_loopfilter.c b/libavcodec/h264_loopfilter.c
index 2440cfa831..c164a289b7 100644
--- a/libavcodec/h264_loopfilter.c
+++ b/libavcodec/h264_loopfilter.c
@@ -143,7 +143,7 @@  static av_always_inline void filter_mb_edgecv(uint8_t *pix, int stride,
 
 static av_always_inline void filter_mb_mbaff_edgev(const H264Context *h, uint8_t *pix,
                                                    int stride,
-                                                   const int16_t bS[7], int bsi,
+                                                   const int16_t bS[ /* 1 + 2 * bsi */ ], int bsi,
                                                    int qp, int a, int b,
                                                    int intra)
 {
@@ -166,7 +166,7 @@  static av_always_inline void filter_mb_mbaff_edgev(const H264Context *h, uint8_t
 
 static av_always_inline void filter_mb_mbaff_edgecv(const H264Context *h,
                                                     uint8_t *pix, int stride,
-                                                    const int16_t bS[7],
+                                                    const int16_t bS[ /* 1 + 2 * bsi */ ],
                                                     int bsi, int qp, int a,
                                                     int b, int intra)
 {