diff --git a/libavcodec/msmpeg4.c b/libavcodec/msmpeg4.c
index 7d829cded56c6d5c75fd8b1342bee149870a631b..cd74850f954726635fd404d171a5437fbc2c078a 100644
--- a/libavcodec/msmpeg4.c
+++ b/libavcodec/msmpeg4.c
@@ -1170,6 +1170,8 @@ int ff_msmpeg4_decode_init(MpegEncContext *s)
         break;
     }
     
+    s->slice_height= s->mb_height; //to avoid 1/0 if the first frame isnt a keyframe
+    
     return 0;
 }