diff mbox

[FFmpeg-devel,3/3] avcodec/mpeg4videodec: Avoid possibly aliasing violating casts

Message ID 20180128012902.22504-3-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer Jan. 28, 2018, 1:29 a.m. UTC
Found-by: kierank

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/mpeg4videodec.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Kieran Kunhya Jan. 28, 2018, 3:13 a.m. UTC | #1
All 3 ok.
Michael Niedermayer Jan. 28, 2018, 6:40 p.m. UTC | #2
On Sun, Jan 28, 2018 at 03:13:44AM +0000, Kieran Kunhya wrote:
> All 3 ok.

will apply

thx

[...]
diff mbox

Patch

diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index ba332de531..756753e2fc 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -1256,10 +1256,12 @@  not_coded:
  */
 static int mpeg4_decode_partitioned_mb(MpegEncContext *s, int16_t block[6][64])
 {
-    Mpeg4DecContext *ctx = (Mpeg4DecContext *)s;
+    Mpeg4DecContext *ctx = s->avctx->priv_data;
     int cbp, mb_type;
     const int xy = s->mb_x + s->mb_y * s->mb_stride;
 
+    av_assert2(s == (void*)ctx);
+
     mb_type = s->current_picture.mb_type[xy];
     cbp     = s->cbp_table[xy];
 
@@ -1341,12 +1343,13 @@  static int mpeg4_decode_partitioned_mb(MpegEncContext *s, int16_t block[6][64])
 
 static int mpeg4_decode_mb(MpegEncContext *s, int16_t block[6][64])
 {
-    Mpeg4DecContext *ctx = (Mpeg4DecContext *)s;
+    Mpeg4DecContext *ctx = s->avctx->priv_data;
     int cbpc, cbpy, i, cbp, pred_x, pred_y, mx, my, dquant;
     int16_t *mot_val;
     static const int8_t quant_tab[4] = { -1, -2, 1, 2 };
     const int xy = s->mb_x + s->mb_y * s->mb_stride;
 
+    av_assert2(s ==  (void*)ctx);
     av_assert2(s->h263_pred);
 
     if (s->pict_type == AV_PICTURE_TYPE_P ||