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

libavcodec/mpegvideo.c:671:1: start of procedure init_context_frame()
669.  * Initialize and allocates MpegEncContext fields dependent on the resolution.
670.  */
671. static int init_context_frame(MpegEncContext *s)
     ^
672. {
673.     int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x, y;

libavcodec/mpegvideo.c:675:5: 
673.     int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x, y;
674. 
675.     s->mb_width   = (s->width + 15) / 16;
         ^
676.     s->mb_stride  = s->mb_width + 1;
677.     s->b8_stride  = s->mb_width * 2 + 1;

libavcodec/mpegvideo.c:676:5: 
674. 
675.     s->mb_width   = (s->width + 15) / 16;
676.     s->mb_stride  = s->mb_width + 1;
         ^
677.     s->b8_stride  = s->mb_width * 2 + 1;
678.     s->b4_stride  = s->mb_width * 4 + 1;

libavcodec/mpegvideo.c:677:5: 
675.     s->mb_width   = (s->width + 15) / 16;
676.     s->mb_stride  = s->mb_width + 1;
677.     s->b8_stride  = s->mb_width * 2 + 1;
         ^
678.     s->b4_stride  = s->mb_width * 4 + 1;
679.     mb_array_size = s->mb_height * s->mb_stride;

libavcodec/mpegvideo.c:678:5: 
676.     s->mb_stride  = s->mb_width + 1;
677.     s->b8_stride  = s->mb_width * 2 + 1;
678.     s->b4_stride  = s->mb_width * 4 + 1;
         ^
679.     mb_array_size = s->mb_height * s->mb_stride;
680.     mv_table_size = (s->mb_height + 2) * s->mb_stride + 1;

libavcodec/mpegvideo.c:679:5: 
677.     s->b8_stride  = s->mb_width * 2 + 1;
678.     s->b4_stride  = s->mb_width * 4 + 1;
679.     mb_array_size = s->mb_height * s->mb_stride;
         ^
680.     mv_table_size = (s->mb_height + 2) * s->mb_stride + 1;
681. 

libavcodec/mpegvideo.c:680:5: 
678.     s->b4_stride  = s->mb_width * 4 + 1;
679.     mb_array_size = s->mb_height * s->mb_stride;
680.     mv_table_size = (s->mb_height + 2) * s->mb_stride + 1;
         ^
681. 
682.     /* set default edge pos, will be overriden

libavcodec/mpegvideo.c:684:5: 
682.     /* set default edge pos, will be overriden
683.      * in decode_header if needed */
684.     s->h_edge_pos = s->mb_width * 16;
         ^
685.     s->v_edge_pos = s->mb_height * 16;
686. 

libavcodec/mpegvideo.c:685:5: 
683.      * in decode_header if needed */
684.     s->h_edge_pos = s->mb_width * 16;
685.     s->v_edge_pos = s->mb_height * 16;
         ^
686. 
687.     s->mb_num     = s->mb_width * s->mb_height;

libavcodec/mpegvideo.c:687:5: 
685.     s->v_edge_pos = s->mb_height * 16;
686. 
687.     s->mb_num     = s->mb_width * s->mb_height;
         ^
688. 
689.     s->block_wrap[0] =

libavcodec/mpegvideo.c:689:5: 
687.     s->mb_num     = s->mb_width * s->mb_height;
688. 
689.     s->block_wrap[0] =
         ^
690.     s->block_wrap[1] =
691.     s->block_wrap[2] =

libavcodec/mpegvideo.c:693:5: 
691.     s->block_wrap[2] =
692.     s->block_wrap[3] = s->b8_stride;
693.     s->block_wrap[4] =
         ^
694.     s->block_wrap[5] = s->mb_stride;
695. 

libavcodec/mpegvideo.c:696:5: 
694.     s->block_wrap[5] = s->mb_stride;
695. 
696.     y_size  = s->b8_stride * (2 * s->mb_height + 1);
         ^
697.     c_size  = s->mb_stride * (s->mb_height + 1);
698.     yc_size = y_size + 2   * c_size;

libavcodec/mpegvideo.c:697:5: 
695. 
696.     y_size  = s->b8_stride * (2 * s->mb_height + 1);
697.     c_size  = s->mb_stride * (s->mb_height + 1);
         ^
698.     yc_size = y_size + 2   * c_size;
699. 

libavcodec/mpegvideo.c:698:5: 
696.     y_size  = s->b8_stride * (2 * s->mb_height + 1);
697.     c_size  = s->mb_stride * (s->mb_height + 1);
698.     yc_size = y_size + 2   * c_size;
         ^
699. 
700.     FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(int),

libavcodec/mpegvideo.c:700:5: 
698.     yc_size = y_size + 2   * c_size;
699. 
700.     FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(int),
         ^
701.                       fail); // error ressilience code looks cleaner with this
702.     for (y = 0; y < s->mb_height; y++)

libavutil/mem.c:161:1: start of procedure av_mallocz()
  159. }
  160. 
  161. void *av_mallocz(size_t size)
       ^
  162. {
  163.     void *ptr = av_malloc(size);

libavutil/mem.c:163:5: 
  161. void *av_mallocz(size_t size)
  162. {
  163.     void *ptr = av_malloc(size);
           ^
  164.     if (ptr)
  165.         memset(ptr, 0, size);

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

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

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

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

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

libavutil/mem.c:164:9: Taking false branch
  162. {
  163.     void *ptr = av_malloc(size);
  164.     if (ptr)
               ^
  165.         memset(ptr, 0, size);
  166.     return ptr;

libavutil/mem.c:166:5: 
  164.     if (ptr)
  165.         memset(ptr, 0, size);
  166.     return ptr;
           ^
  167. }
  168. 

libavutil/mem.c:167:1: return from a call to av_mallocz
  165.         memset(ptr, 0, size);
  166.     return ptr;
  167. }
       ^
  168. 
  169. char *av_strdup(const char *s)

libavcodec/mpegvideo.c:700:5: Taking true branch
698.     yc_size = y_size + 2   * c_size;
699. 
700.     FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(int),
         ^
701.                       fail); // error ressilience code looks cleaner with this
702.     for (y = 0; y < s->mb_height; y++)

libavcodec/mpegvideo.c:700:5: Taking false branch
698.     yc_size = y_size + 2   * c_size;
699. 
700.     FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(int),
         ^
701.                       fail); // error ressilience code looks cleaner with this
702.     for (y = 0; y < s->mb_height; y++)

libavcodec/mpegvideo.c:702:10: 
700.     FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(int),
701.                       fail); // error ressilience code looks cleaner with this
702.     for (y = 0; y < s->mb_height; y++)
              ^
703.         for (x = 0; x < s->mb_width; x++)
704.             s->mb_index2xy[x + y * s->mb_width] = x + y * s->mb_stride;

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

libavcodec/mpegvideo.c:706:5: 
704.             s->mb_index2xy[x + y * s->mb_width] = x + y * s->mb_stride;
705. 
706.     s->mb_index2xy[s->mb_height * s->mb_width] =
         ^
707.         (s->mb_height - 1) * s->mb_stride + s->mb_width; // FIXME really needed?
708. 
