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

libavcodec/mpegvideo.c:879:1: start of procedure init_context_frame()
877.  * Initialize and allocates MpegEncContext fields dependent on the resolution.
878.  */
879. static int init_context_frame(MpegEncContext *s)
     ^
880. {
881.     int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x, y;

libavcodec/mpegvideo.c:883:5: 
881.     int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x, y;
882. 
883.     s->mb_width   = (s->width + 15) / 16;
         ^
884.     s->mb_stride  = s->mb_width + 1;
885.     s->b8_stride  = s->mb_width * 2 + 1;

libavcodec/mpegvideo.c:884:5: 
882. 
883.     s->mb_width   = (s->width + 15) / 16;
884.     s->mb_stride  = s->mb_width + 1;
         ^
885.     s->b8_stride  = s->mb_width * 2 + 1;
886.     s->b4_stride  = s->mb_width * 4 + 1;

libavcodec/mpegvideo.c:885:5: 
883.     s->mb_width   = (s->width + 15) / 16;
884.     s->mb_stride  = s->mb_width + 1;
885.     s->b8_stride  = s->mb_width * 2 + 1;
         ^
886.     s->b4_stride  = s->mb_width * 4 + 1;
887.     mb_array_size = s->mb_height * s->mb_stride;

libavcodec/mpegvideo.c:886:5: 
884.     s->mb_stride  = s->mb_width + 1;
885.     s->b8_stride  = s->mb_width * 2 + 1;
886.     s->b4_stride  = s->mb_width * 4 + 1;
         ^
887.     mb_array_size = s->mb_height * s->mb_stride;
888.     mv_table_size = (s->mb_height + 2) * s->mb_stride + 1;

libavcodec/mpegvideo.c:887:5: 
885.     s->b8_stride  = s->mb_width * 2 + 1;
886.     s->b4_stride  = s->mb_width * 4 + 1;
887.     mb_array_size = s->mb_height * s->mb_stride;
         ^
888.     mv_table_size = (s->mb_height + 2) * s->mb_stride + 1;
889. 

libavcodec/mpegvideo.c:888:5: 
886.     s->b4_stride  = s->mb_width * 4 + 1;
887.     mb_array_size = s->mb_height * s->mb_stride;
888.     mv_table_size = (s->mb_height + 2) * s->mb_stride + 1;
         ^
889. 
890.     /* set default edge pos, will be overriden

libavcodec/mpegvideo.c:892:5: 
890.     /* set default edge pos, will be overriden
891.      * in decode_header if needed */
892.     s->h_edge_pos = s->mb_width * 16;
         ^
893.     s->v_edge_pos = s->mb_height * 16;
894. 

libavcodec/mpegvideo.c:893:5: 
891.      * in decode_header if needed */
892.     s->h_edge_pos = s->mb_width * 16;
893.     s->v_edge_pos = s->mb_height * 16;
         ^
894. 
895.     s->mb_num     = s->mb_width * s->mb_height;

libavcodec/mpegvideo.c:895:5: 
893.     s->v_edge_pos = s->mb_height * 16;
894. 
895.     s->mb_num     = s->mb_width * s->mb_height;
         ^
896. 
897.     s->block_wrap[0] =

libavcodec/mpegvideo.c:897:5: 
895.     s->mb_num     = s->mb_width * s->mb_height;
896. 
897.     s->block_wrap[0] =
         ^
898.     s->block_wrap[1] =
899.     s->block_wrap[2] =

libavcodec/mpegvideo.c:901:5: 
899.     s->block_wrap[2] =
900.     s->block_wrap[3] = s->b8_stride;
901.     s->block_wrap[4] =
         ^
902.     s->block_wrap[5] = s->mb_stride;
903. 

libavcodec/mpegvideo.c:904:5: 
902.     s->block_wrap[5] = s->mb_stride;
903. 
904.     y_size  = s->b8_stride * (2 * s->mb_height + 1);
         ^
905.     c_size  = s->mb_stride * (s->mb_height + 1);
906.     yc_size = y_size + 2   * c_size;

libavcodec/mpegvideo.c:905:5: 
903. 
904.     y_size  = s->b8_stride * (2 * s->mb_height + 1);
905.     c_size  = s->mb_stride * (s->mb_height + 1);
         ^
906.     yc_size = y_size + 2   * c_size;
907. 

libavcodec/mpegvideo.c:906:5: 
904.     y_size  = s->b8_stride * (2 * s->mb_height + 1);
905.     c_size  = s->mb_stride * (s->mb_height + 1);
906.     yc_size = y_size + 2   * c_size;
         ^
907. 
908.     FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(int),

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

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

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

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

libavcodec/mpegvideo.c:914:5: 
912.             s->mb_index2xy[x + y * s->mb_width] = x + y * s->mb_stride;
913. 
914.     s->mb_index2xy[s->mb_height * s->mb_width] =
         ^
915.         (s->mb_height - 1) * s->mb_stride + s->mb_width; // FIXME really needed?
916. 
