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

libavcodec/mpegvideo.c:729:1: start of procedure init_context_frame()
727.  * Initialize and allocates MpegEncContext fields dependent on the resolution.
728.  */
729. static int init_context_frame(MpegEncContext *s)
     ^
730. {
731.     int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x, y;

libavcodec/mpegvideo.c:733:5: 
731.     int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x, y;
732. 
733.     s->mb_width   = (s->width + 15) / 16;
         ^
734.     s->mb_stride  = s->mb_width + 1;
735.     s->b8_stride  = s->mb_width * 2 + 1;

libavcodec/mpegvideo.c:734:5: 
732. 
733.     s->mb_width   = (s->width + 15) / 16;
734.     s->mb_stride  = s->mb_width + 1;
         ^
735.     s->b8_stride  = s->mb_width * 2 + 1;
736.     s->b4_stride  = s->mb_width * 4 + 1;

libavcodec/mpegvideo.c:735:5: 
733.     s->mb_width   = (s->width + 15) / 16;
734.     s->mb_stride  = s->mb_width + 1;
735.     s->b8_stride  = s->mb_width * 2 + 1;
         ^
736.     s->b4_stride  = s->mb_width * 4 + 1;
737.     mb_array_size = s->mb_height * s->mb_stride;

libavcodec/mpegvideo.c:736:5: 
734.     s->mb_stride  = s->mb_width + 1;
735.     s->b8_stride  = s->mb_width * 2 + 1;
736.     s->b4_stride  = s->mb_width * 4 + 1;
         ^
737.     mb_array_size = s->mb_height * s->mb_stride;
738.     mv_table_size = (s->mb_height + 2) * s->mb_stride + 1;

libavcodec/mpegvideo.c:737:5: 
735.     s->b8_stride  = s->mb_width * 2 + 1;
736.     s->b4_stride  = s->mb_width * 4 + 1;
737.     mb_array_size = s->mb_height * s->mb_stride;
         ^
738.     mv_table_size = (s->mb_height + 2) * s->mb_stride + 1;
739. 

libavcodec/mpegvideo.c:738:5: 
736.     s->b4_stride  = s->mb_width * 4 + 1;
737.     mb_array_size = s->mb_height * s->mb_stride;
738.     mv_table_size = (s->mb_height + 2) * s->mb_stride + 1;
         ^
739. 
740.     /* set default edge pos, will be overriden

libavcodec/mpegvideo.c:742:5: 
740.     /* set default edge pos, will be overriden
741.      * in decode_header if needed */
742.     s->h_edge_pos = s->mb_width * 16;
         ^
743.     s->v_edge_pos = s->mb_height * 16;
744. 

libavcodec/mpegvideo.c:743:5: 
741.      * in decode_header if needed */
742.     s->h_edge_pos = s->mb_width * 16;
743.     s->v_edge_pos = s->mb_height * 16;
         ^
744. 
745.     s->mb_num     = s->mb_width * s->mb_height;

libavcodec/mpegvideo.c:745:5: 
743.     s->v_edge_pos = s->mb_height * 16;
744. 
745.     s->mb_num     = s->mb_width * s->mb_height;
         ^
746. 
747.     s->block_wrap[0] =

libavcodec/mpegvideo.c:747:5: 
745.     s->mb_num     = s->mb_width * s->mb_height;
746. 
747.     s->block_wrap[0] =
         ^
748.     s->block_wrap[1] =
749.     s->block_wrap[2] =

libavcodec/mpegvideo.c:751:5: 
749.     s->block_wrap[2] =
750.     s->block_wrap[3] = s->b8_stride;
751.     s->block_wrap[4] =
         ^
752.     s->block_wrap[5] = s->mb_stride;
753. 

libavcodec/mpegvideo.c:754:5: 
752.     s->block_wrap[5] = s->mb_stride;
753. 
754.     y_size  = s->b8_stride * (2 * s->mb_height + 1);
         ^
755.     c_size  = s->mb_stride * (s->mb_height + 1);
756.     yc_size = y_size + 2   * c_size;

libavcodec/mpegvideo.c:755:5: 
753. 
754.     y_size  = s->b8_stride * (2 * s->mb_height + 1);
755.     c_size  = s->mb_stride * (s->mb_height + 1);
         ^
756.     yc_size = y_size + 2   * c_size;
757. 

libavcodec/mpegvideo.c:756:5: 
754.     y_size  = s->b8_stride * (2 * s->mb_height + 1);
755.     c_size  = s->mb_stride * (s->mb_height + 1);
756.     yc_size = y_size + 2   * c_size;
         ^
757. 
758.     FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(int),

libavcodec/mpegvideo.c:758:5: 
756.     yc_size = y_size + 2   * c_size;
757. 
758.     FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(int),
         ^
759.                       fail); // error ressilience code looks cleaner with this
760.     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:758:5: Taking true branch
756.     yc_size = y_size + 2   * c_size;
757. 
758.     FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(int),
         ^
759.                       fail); // error ressilience code looks cleaner with this
760.     for (y = 0; y < s->mb_height; y++)

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

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

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

libavcodec/mpegvideo.c:764:5: 
762.             s->mb_index2xy[x + y * s->mb_width] = x + y * s->mb_stride;
763. 
764.     s->mb_index2xy[s->mb_height * s->mb_width] =
         ^
765.         (s->mb_height - 1) * s->mb_stride + s->mb_width; // FIXME really needed?
766. 
