libavcodec/mpegvideo.c:657: error: Null Dereference
  pointer `s->mb_index2xy` last assigned on line 651 could be null and is dereferenced at line 657, column 5.

libavcodec/mpegvideo.c:623:1: start of procedure init_context_frame()
621.  * Initialize and allocates MpegEncContext fields dependent on the resolution.
622.  */
623. static int init_context_frame(MpegEncContext *s)
     ^
624. {
625.     int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x, y;

libavcodec/mpegvideo.c:627:5: 
625.     int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x, y;
626. 
627.     s->mb_width   = (s->width + 15) / 16;
         ^
628.     s->mb_stride  = s->mb_width + 1;
629.     s->b8_stride  = s->mb_width * 2 + 1;

libavcodec/mpegvideo.c:628:5: 
626. 
627.     s->mb_width   = (s->width + 15) / 16;
628.     s->mb_stride  = s->mb_width + 1;
         ^
629.     s->b8_stride  = s->mb_width * 2 + 1;
630.     mb_array_size = s->mb_height * s->mb_stride;

libavcodec/mpegvideo.c:629:5: 
627.     s->mb_width   = (s->width + 15) / 16;
628.     s->mb_stride  = s->mb_width + 1;
629.     s->b8_stride  = s->mb_width * 2 + 1;
         ^
630.     mb_array_size = s->mb_height * s->mb_stride;
631.     mv_table_size = (s->mb_height + 2) * s->mb_stride + 1;

libavcodec/mpegvideo.c:630:5: 
628.     s->mb_stride  = s->mb_width + 1;
629.     s->b8_stride  = s->mb_width * 2 + 1;
630.     mb_array_size = s->mb_height * s->mb_stride;
         ^
631.     mv_table_size = (s->mb_height + 2) * s->mb_stride + 1;
632. 

libavcodec/mpegvideo.c:631:5: 
629.     s->b8_stride  = s->mb_width * 2 + 1;
630.     mb_array_size = s->mb_height * s->mb_stride;
631.     mv_table_size = (s->mb_height + 2) * s->mb_stride + 1;
         ^
632. 
633.     /* set default edge pos, will be overridden

libavcodec/mpegvideo.c:635:5: 
633.     /* set default edge pos, will be overridden
634.      * in decode_header if needed */
635.     s->h_edge_pos = s->mb_width * 16;
         ^
636.     s->v_edge_pos = s->mb_height * 16;
637. 

libavcodec/mpegvideo.c:636:5: 
634.      * in decode_header if needed */
635.     s->h_edge_pos = s->mb_width * 16;
636.     s->v_edge_pos = s->mb_height * 16;
         ^
637. 
638.     s->mb_num     = s->mb_width * s->mb_height;

libavcodec/mpegvideo.c:638:5: 
636.     s->v_edge_pos = s->mb_height * 16;
637. 
638.     s->mb_num     = s->mb_width * s->mb_height;
         ^
639. 
640.     s->block_wrap[0] =

libavcodec/mpegvideo.c:640:5: 
638.     s->mb_num     = s->mb_width * s->mb_height;
639. 
640.     s->block_wrap[0] =
         ^
641.     s->block_wrap[1] =
642.     s->block_wrap[2] =

libavcodec/mpegvideo.c:644:5: 
642.     s->block_wrap[2] =
643.     s->block_wrap[3] = s->b8_stride;
644.     s->block_wrap[4] =
         ^
645.     s->block_wrap[5] = s->mb_stride;
646. 

libavcodec/mpegvideo.c:647:5: 
645.     s->block_wrap[5] = s->mb_stride;
646. 
647.     y_size  = s->b8_stride * (2 * s->mb_height + 1);
         ^
648.     c_size  = s->mb_stride * (s->mb_height + 1);
649.     yc_size = y_size + 2   * c_size;

libavcodec/mpegvideo.c:648:5: 
646. 
647.     y_size  = s->b8_stride * (2 * s->mb_height + 1);
648.     c_size  = s->mb_stride * (s->mb_height + 1);
         ^
649.     yc_size = y_size + 2   * c_size;
650. 

libavcodec/mpegvideo.c:649:5: 
647.     y_size  = s->b8_stride * (2 * s->mb_height + 1);
648.     c_size  = s->mb_stride * (s->mb_height + 1);
649.     yc_size = y_size + 2   * c_size;
         ^
650. 
651.     FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(int),

libavcodec/mpegvideo.c:651:5: 
649.     yc_size = y_size + 2   * c_size;
650. 
651.     FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(int),
         ^
652.                       fail); // error resilience code looks cleaner with this
653.     for (y = 0; y < s->mb_height; y++)

libavutil/mem.c:211:1: start of procedure av_mallocz()
  209. }
  210. 
  211. void *av_mallocz(size_t size)
       ^
  212. {
  213.     void *ptr = av_malloc(size);

libavutil/mem.c:213:5: 
  211. void *av_mallocz(size_t size)
  212. {
  213.     void *ptr = av_malloc(size);
           ^
  214.     if (ptr)
  215.         memset(ptr, 0, size);

libavutil/mem.c:62:1: start of procedure av_malloc()
    60.  * linker will do it automatically. */
    61. 
    62. void *av_malloc(size_t size)
        ^
    63. {
    64.     void *ptr = NULL;

libavutil/mem.c:64:5: 
    62. void *av_malloc(size_t size)
    63. {
    64.     void *ptr = NULL;
            ^
    65. #if CONFIG_MEMALIGN_HACK
    66.     long diff;

libavutil/mem.c:70:9: Taking true branch
    68. 
    69.     /* let's disallow possibly ambiguous cases */
    70.     if (size > (INT_MAX - 32) || !size)
                ^
    71.         return NULL;
    72. 

libavutil/mem.c:71:9: 
    69.     /* let's disallow possibly ambiguous cases */
    70.     if (size > (INT_MAX - 32) || !size)
    71.         return NULL;
                ^
    72. 
    73. #if CONFIG_MEMALIGN_HACK

libavutil/mem.c:115:1: return from a call to av_malloc
    113. #endif
    114.     return ptr;
    115. }
         ^
    116. 
    117. void *av_realloc(void *ptr, size_t size)

libavutil/mem.c:214:9: Taking false branch
  212. {
  213.     void *ptr = av_malloc(size);
  214.     if (ptr)
               ^
  215.         memset(ptr, 0, size);
  216.     return ptr;

libavutil/mem.c:216:5: 
  214.     if (ptr)
  215.         memset(ptr, 0, size);
  216.     return ptr;
           ^
  217. }
  218. 

libavutil/mem.c:217:1: return from a call to av_mallocz
  215.         memset(ptr, 0, size);
  216.     return ptr;
  217. }
       ^
  218. 
  219. char *av_strdup(const char *s)

libavcodec/mpegvideo.c:651:5: Taking true branch
649.     yc_size = y_size + 2   * c_size;
650. 
651.     FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(int),
         ^
652.                       fail); // error resilience code looks cleaner with this
653.     for (y = 0; y < s->mb_height; y++)

libavcodec/mpegvideo.c:651:5: Taking false branch
649.     yc_size = y_size + 2   * c_size;
650. 
651.     FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(int),
         ^
652.                       fail); // error resilience code looks cleaner with this
653.     for (y = 0; y < s->mb_height; y++)

libavcodec/mpegvideo.c:653:10: 
651.     FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(int),
652.                       fail); // error resilience code looks cleaner with this
653.     for (y = 0; y < s->mb_height; y++)
              ^
654.         for (x = 0; x < s->mb_width; x++)
655.             s->mb_index2xy[x + y * s->mb_width] = x + y * s->mb_stride;

libavcodec/mpegvideo.c:653:17: Loop condition is false. Leaving loop
651.     FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(int),
652.                       fail); // error resilience code looks cleaner with this
653.     for (y = 0; y < s->mb_height; y++)
                     ^
654.         for (x = 0; x < s->mb_width; x++)
655.             s->mb_index2xy[x + y * s->mb_width] = x + y * s->mb_stride;

libavcodec/mpegvideo.c:657:5: 
655.             s->mb_index2xy[x + y * s->mb_width] = x + y * s->mb_stride;
656. 
657.     s->mb_index2xy[s->mb_height * s->mb_width] =
         ^
658.         (s->mb_height - 1) * s->mb_stride + s->mb_width; // FIXME really needed?
659. 
