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

libavcodec/mpegvideo.c:1018:1: start of procedure init_context_frame()
1016.  * Initialize and allocates MpegEncContext fields dependent on the resolution.
1017.  */
1018. static int init_context_frame(MpegEncContext *s)
      ^
1019. {
1020.     int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x, y;

libavcodec/mpegvideo.c:1022:5: 
1020.     int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x, y;
1021. 
1022.     s->mb_width   = (s->width + 15) / 16;
          ^
1023.     s->mb_stride  = s->mb_width + 1;
1024.     s->b8_stride  = s->mb_width * 2 + 1;

libavcodec/mpegvideo.c:1023:5: 
1021. 
1022.     s->mb_width   = (s->width + 15) / 16;
1023.     s->mb_stride  = s->mb_width + 1;
          ^
1024.     s->b8_stride  = s->mb_width * 2 + 1;
1025.     mb_array_size = s->mb_height * s->mb_stride;

libavcodec/mpegvideo.c:1024:5: 
1022.     s->mb_width   = (s->width + 15) / 16;
1023.     s->mb_stride  = s->mb_width + 1;
1024.     s->b8_stride  = s->mb_width * 2 + 1;
          ^
1025.     mb_array_size = s->mb_height * s->mb_stride;
1026.     mv_table_size = (s->mb_height + 2) * s->mb_stride + 1;

libavcodec/mpegvideo.c:1025:5: 
1023.     s->mb_stride  = s->mb_width + 1;
1024.     s->b8_stride  = s->mb_width * 2 + 1;
1025.     mb_array_size = s->mb_height * s->mb_stride;
          ^
1026.     mv_table_size = (s->mb_height + 2) * s->mb_stride + 1;
1027. 

libavcodec/mpegvideo.c:1026:5: 
1024.     s->b8_stride  = s->mb_width * 2 + 1;
1025.     mb_array_size = s->mb_height * s->mb_stride;
1026.     mv_table_size = (s->mb_height + 2) * s->mb_stride + 1;
          ^
1027. 
1028.     /* set default edge pos, will be overriden

libavcodec/mpegvideo.c:1030:5: 
1028.     /* set default edge pos, will be overriden
1029.      * in decode_header if needed */
1030.     s->h_edge_pos = s->mb_width * 16;
          ^
1031.     s->v_edge_pos = s->mb_height * 16;
1032. 

libavcodec/mpegvideo.c:1031:5: 
1029.      * in decode_header if needed */
1030.     s->h_edge_pos = s->mb_width * 16;
1031.     s->v_edge_pos = s->mb_height * 16;
          ^
1032. 
1033.     s->mb_num     = s->mb_width * s->mb_height;

libavcodec/mpegvideo.c:1033:5: 
1031.     s->v_edge_pos = s->mb_height * 16;
1032. 
1033.     s->mb_num     = s->mb_width * s->mb_height;
          ^
1034. 
1035.     s->block_wrap[0] =

libavcodec/mpegvideo.c:1035:5: 
1033.     s->mb_num     = s->mb_width * s->mb_height;
1034. 
1035.     s->block_wrap[0] =
          ^
1036.     s->block_wrap[1] =
1037.     s->block_wrap[2] =

libavcodec/mpegvideo.c:1039:5: 
1037.     s->block_wrap[2] =
1038.     s->block_wrap[3] = s->b8_stride;
1039.     s->block_wrap[4] =
          ^
1040.     s->block_wrap[5] = s->mb_stride;
1041. 

libavcodec/mpegvideo.c:1042:5: 
1040.     s->block_wrap[5] = s->mb_stride;
1041. 
1042.     y_size  = s->b8_stride * (2 * s->mb_height + 1);
          ^
1043.     c_size  = s->mb_stride * (s->mb_height + 1);
1044.     yc_size = y_size + 2   * c_size;

libavcodec/mpegvideo.c:1043:5: 
1041. 
1042.     y_size  = s->b8_stride * (2 * s->mb_height + 1);
1043.     c_size  = s->mb_stride * (s->mb_height + 1);
          ^
1044.     yc_size = y_size + 2   * c_size;
1045. 

libavcodec/mpegvideo.c:1044:5: 
1042.     y_size  = s->b8_stride * (2 * s->mb_height + 1);
1043.     c_size  = s->mb_stride * (s->mb_height + 1);
1044.     yc_size = y_size + 2   * c_size;
          ^
1045. 
1046.     FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_index2xy, (s->mb_num + 1) * sizeof(int),

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

libavutil/mem.c:211:1: start of procedure av_mallocz()
  209. }
  210. 
  211. void *av_mallocz(size_t size)
       ^
  212. {
  213.     void *ptr = av_malloc(size);

libavutil/mem.c:213:5: 
  211. void *av_mallocz(size_t size)
  212. {
  213.     void *ptr = av_malloc(size);
           ^
  214.     if (ptr)
  215.         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:214:9: Taking false branch
  212. {
  213.     void *ptr = av_malloc(size);
  214.     if (ptr)
               ^
  215.         memset(ptr, 0, size);
  216.     return ptr;

libavutil/mem.c:216:5: 
  214.     if (ptr)
  215.         memset(ptr, 0, size);
  216.     return ptr;
           ^
  217. }
  218. 

libavutil/mem.c:217:1: return from a call to av_mallocz
  215.         memset(ptr, 0, size);
  216.     return ptr;
  217. }
       ^
  218. 
  219. char *av_strdup(const char *s)

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

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

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

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

libavcodec/mpegvideo.c:1052:5: 
1050.             s->mb_index2xy[x + y * s->mb_width] = x + y * s->mb_stride;
1051. 
1052.     s->mb_index2xy[s->mb_height * s->mb_width] =
          ^
1053.         (s->mb_height - 1) * s->mb_stride + s->mb_width; // FIXME really needed?
1054. 
