diff mbox series

[FFmpeg-devel] mpeg4videoenc: Don't crash with -fsanitize=bounds

Message ID 20200422043419.71842-1-vitalybuka@google.com
State Accepted
Commit f163d30de2090a7275f1fb8ad69258576f12c1a2
Headers show
Series [FFmpeg-devel] mpeg4videoenc: Don't crash with -fsanitize=bounds | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Vitaly Buka April 22, 2020, 4:34 a.m. UTC
Also the patch makes this code consistent with mpeg4videodec.c
---
 libavcodec/mpeg4videoenc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Michael Niedermayer April 22, 2020, 9:16 p.m. UTC | #1
On Tue, Apr 21, 2020 at 09:34:19PM -0700, Vitaly Buka wrote:
> Also the patch makes this code consistent with mpeg4videodec.c
> ---
>  libavcodec/mpeg4videoenc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

will apply

thx

[...]
diff mbox series

Patch

diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index f6a5992df7..2cd5a8c015 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -104,7 +104,7 @@  static inline void restore_ac_coeffs(MpegEncContext *s, int16_t block[6][64],
     memcpy(s->block_last_index, zigzag_last_index, sizeof(int) * 6);
 
     for (n = 0; n < 6; n++) {
-        int16_t *ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
+        int16_t *ac_val = &s->ac_val[0][0][0] + s->block_index[n] * 16;
 
         st[n] = s->intra_scantable.permutated;
         if (dir[n]) {
@@ -143,7 +143,7 @@  static inline int decide_ac_pred(MpegEncContext *s, int16_t block[6][64],
         score -= get_block_rate(s, block[n], s->block_last_index[n],
                                 s->intra_scantable.permutated);
 
-        ac_val  = s->ac_val[0][0] + s->block_index[n] * 16;
+        ac_val  = &s->ac_val[0][0][0] + s->block_index[n] * 16;
         ac_val1 = ac_val;
         if (dir[n]) {
             const int xy = s->mb_x + s->mb_y * s->mb_stride - s->mb_stride;