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

libavcodec/mpegvideo.c:838:1: start of procedure init_context_frame()
836.  * Initialize and allocates MpegEncContext fields dependent on the resolution.
837.  */
838. static int init_context_frame(MpegEncContext *s)
     ^
839. {
840.     int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x, y;

libavcodec/mpegvideo.c:842:5: 
840.     int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x, y;
841. 
842.     s->mb_width   = (s->width + 15) / 16;
         ^
843.     s->mb_stride  = s->mb_width + 1;
844.     s->b8_stride  = s->mb_width * 2 + 1;

libavcodec/mpegvideo.c:843:5: 
841. 
842.     s->mb_width   = (s->width + 15) / 16;
843.     s->mb_stride  = s->mb_width + 1;
         ^
844.     s->b8_stride  = s->mb_width * 2 + 1;
845.     s->b4_stride  = s->mb_width * 4 + 1;

libavcodec/mpegvideo.c:844:5: 
842.     s->mb_width   = (s->width + 15) / 16;
843.     s->mb_stride  = s->mb_width + 1;
844.     s->b8_stride  = s->mb_width * 2 + 1;
         ^
845.     s->b4_stride  = s->mb_width * 4 + 1;
846.     mb_array_size = s->mb_height * s->mb_stride;

libavcodec/mpegvideo.c:845:5: 
843.     s->mb_stride  = s->mb_width + 1;
844.     s->b8_stride  = s->mb_width * 2 + 1;
845.     s->b4_stride  = s->mb_width * 4 + 1;
         ^
846.     mb_array_size = s->mb_height * s->mb_stride;
847.     mv_table_size = (s->mb_height + 2) * s->mb_stride + 1;

libavcodec/mpegvideo.c:846:5: 
844.     s->b8_stride  = s->mb_width * 2 + 1;
845.     s->b4_stride  = s->mb_width * 4 + 1;
846.     mb_array_size = s->mb_height * s->mb_stride;
         ^
847.     mv_table_size = (s->mb_height + 2) * s->mb_stride + 1;
848. 

libavcodec/mpegvideo.c:847:5: 
845.     s->b4_stride  = s->mb_width * 4 + 1;
846.     mb_array_size = s->mb_height * s->mb_stride;
847.     mv_table_size = (s->mb_height + 2) * s->mb_stride + 1;
         ^
848. 
849.     /* set default edge pos, will be overriden

libavcodec/mpegvideo.c:851:5: 
849.     /* set default edge pos, will be overriden
850.      * in decode_header if needed */
851.     s->h_edge_pos = s->mb_width * 16;
         ^
852.     s->v_edge_pos = s->mb_height * 16;
853. 

libavcodec/mpegvideo.c:852:5: 
850.      * in decode_header if needed */
851.     s->h_edge_pos = s->mb_width * 16;
852.     s->v_edge_pos = s->mb_height * 16;
         ^
853. 
854.     s->mb_num     = s->mb_width * s->mb_height;

libavcodec/mpegvideo.c:854:5: 
852.     s->v_edge_pos = s->mb_height * 16;
853. 
854.     s->mb_num     = s->mb_width * s->mb_height;
         ^
855. 
856.     s->block_wrap[0] =

libavcodec/mpegvideo.c:856:5: 
854.     s->mb_num     = s->mb_width * s->mb_height;
855. 
856.     s->block_wrap[0] =
         ^
857.     s->block_wrap[1] =
858.     s->block_wrap[2] =

libavcodec/mpegvideo.c:860:5: 
858.     s->block_wrap[2] =
859.     s->block_wrap[3] = s->b8_stride;
860.     s->block_wrap[4] =
         ^
861.     s->block_wrap[5] = s->mb_stride;
862. 

libavcodec/mpegvideo.c:863:5: 
861.     s->block_wrap[5] = s->mb_stride;
862. 
863.     y_size  = s->b8_stride * (2 * s->mb_height + 1);
         ^
864.     c_size  = s->mb_stride * (s->mb_height + 1);
865.     yc_size = y_size + 2   * c_size;

libavcodec/mpegvideo.c:864:5: 
862. 
863.     y_size  = s->b8_stride * (2 * s->mb_height + 1);
864.     c_size  = s->mb_stride * (s->mb_height + 1);
         ^
865.     yc_size = y_size + 2   * c_size;
866. 

libavcodec/mpegvideo.c:865:5: 
863.     y_size  = s->b8_stride * (2 * s->mb_height + 1);
864.     c_size  = s->mb_stride * (s->mb_height + 1);
865.     yc_size = y_size + 2   * c_size;
         ^
866. 
867.     FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(int),

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

libavutil/mem.c:205:1: start of procedure av_mallocz()
  203. }
  204. 
  205. void *av_mallocz(size_t size)
       ^
  206. {
  207.     void *ptr = av_malloc(size);

libavutil/mem.c:207:5: 
  205. void *av_mallocz(size_t size)
  206. {
  207.     void *ptr = av_malloc(size);
           ^
  208.     if (ptr)
  209.         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:208:9: Taking false branch
  206. {
  207.     void *ptr = av_malloc(size);
  208.     if (ptr)
               ^
  209.         memset(ptr, 0, size);
  210.     return ptr;

libavutil/mem.c:210:5: 
  208.     if (ptr)
  209.         memset(ptr, 0, size);
  210.     return ptr;
           ^
  211. }
  212. 

libavutil/mem.c:211:1: return from a call to av_mallocz
  209.         memset(ptr, 0, size);
  210.     return ptr;
  211. }
       ^
  212. 
  213. char *av_strdup(const char *s)

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

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

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

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

libavcodec/mpegvideo.c:873:5: 
871.             s->mb_index2xy[x + y * s->mb_width] = x + y * s->mb_stride;
872. 
873.     s->mb_index2xy[s->mb_height * s->mb_width] =
         ^
874.         (s->mb_height - 1) * s->mb_stride + s->mb_width; // FIXME really needed?
875. 
