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

libavcodec/mpegvideo.c:719:1: start of procedure init_context_frame()
717.  * Initialize and allocates MpegEncContext fields dependent on the resolution.
718.  */
719. static int init_context_frame(MpegEncContext *s)
     ^
720. {
721.     int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x, y;

libavcodec/mpegvideo.c:723:5: 
721.     int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x, y;
722. 
723.     s->mb_width   = (s->width + 15) / 16;
         ^
724.     s->mb_stride  = s->mb_width + 1;
725.     s->b8_stride  = s->mb_width * 2 + 1;

libavcodec/mpegvideo.c:724:5: 
722. 
723.     s->mb_width   = (s->width + 15) / 16;
724.     s->mb_stride  = s->mb_width + 1;
         ^
725.     s->b8_stride  = s->mb_width * 2 + 1;
726.     s->b4_stride  = s->mb_width * 4 + 1;

libavcodec/mpegvideo.c:725:5: 
723.     s->mb_width   = (s->width + 15) / 16;
724.     s->mb_stride  = s->mb_width + 1;
725.     s->b8_stride  = s->mb_width * 2 + 1;
         ^
726.     s->b4_stride  = s->mb_width * 4 + 1;
727.     mb_array_size = s->mb_height * s->mb_stride;

libavcodec/mpegvideo.c:726:5: 
724.     s->mb_stride  = s->mb_width + 1;
725.     s->b8_stride  = s->mb_width * 2 + 1;
726.     s->b4_stride  = s->mb_width * 4 + 1;
         ^
727.     mb_array_size = s->mb_height * s->mb_stride;
728.     mv_table_size = (s->mb_height + 2) * s->mb_stride + 1;

libavcodec/mpegvideo.c:727:5: 
725.     s->b8_stride  = s->mb_width * 2 + 1;
726.     s->b4_stride  = s->mb_width * 4 + 1;
727.     mb_array_size = s->mb_height * s->mb_stride;
         ^
728.     mv_table_size = (s->mb_height + 2) * s->mb_stride + 1;
729. 

libavcodec/mpegvideo.c:728:5: 
726.     s->b4_stride  = s->mb_width * 4 + 1;
727.     mb_array_size = s->mb_height * s->mb_stride;
728.     mv_table_size = (s->mb_height + 2) * s->mb_stride + 1;
         ^
729. 
730.     /* set default edge pos, will be overriden

libavcodec/mpegvideo.c:732:5: 
730.     /* set default edge pos, will be overriden
731.      * in decode_header if needed */
732.     s->h_edge_pos = s->mb_width * 16;
         ^
733.     s->v_edge_pos = s->mb_height * 16;
734. 

libavcodec/mpegvideo.c:733:5: 
731.      * in decode_header if needed */
732.     s->h_edge_pos = s->mb_width * 16;
733.     s->v_edge_pos = s->mb_height * 16;
         ^
734. 
735.     s->mb_num     = s->mb_width * s->mb_height;

libavcodec/mpegvideo.c:735:5: 
733.     s->v_edge_pos = s->mb_height * 16;
734. 
735.     s->mb_num     = s->mb_width * s->mb_height;
         ^
736. 
737.     s->block_wrap[0] =

libavcodec/mpegvideo.c:737:5: 
735.     s->mb_num     = s->mb_width * s->mb_height;
736. 
737.     s->block_wrap[0] =
         ^
738.     s->block_wrap[1] =
739.     s->block_wrap[2] =

libavcodec/mpegvideo.c:741:5: 
739.     s->block_wrap[2] =
740.     s->block_wrap[3] = s->b8_stride;
741.     s->block_wrap[4] =
         ^
742.     s->block_wrap[5] = s->mb_stride;
743. 

libavcodec/mpegvideo.c:744:5: 
742.     s->block_wrap[5] = s->mb_stride;
743. 
744.     y_size  = s->b8_stride * (2 * s->mb_height + 1);
         ^
745.     c_size  = s->mb_stride * (s->mb_height + 1);
746.     yc_size = y_size + 2   * c_size;

libavcodec/mpegvideo.c:745:5: 
743. 
744.     y_size  = s->b8_stride * (2 * s->mb_height + 1);
745.     c_size  = s->mb_stride * (s->mb_height + 1);
         ^
746.     yc_size = y_size + 2   * c_size;
747. 

libavcodec/mpegvideo.c:746:5: 
744.     y_size  = s->b8_stride * (2 * s->mb_height + 1);
745.     c_size  = s->mb_stride * (s->mb_height + 1);
746.     yc_size = y_size + 2   * c_size;
         ^
747. 
748.     FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(int),

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

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

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

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

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

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

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

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

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

libavutil/mem.c:163:5: 
  161.     if (ptr)
  162.         memset(ptr, 0, size);
  163.     return ptr;
           ^
  164. }
  165. 

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

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

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

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

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

libavcodec/mpegvideo.c:754:5: 
752.             s->mb_index2xy[x + y * s->mb_width] = x + y * s->mb_stride;
753. 
754.     s->mb_index2xy[s->mb_height * s->mb_width] =
         ^
755.         (s->mb_height - 1) * s->mb_stride + s->mb_width; // FIXME really needed?
756. 
