libavcodec/mpeg12.c:97: error: Null Dereference
  pointer `rl->vlc.table` last assigned on line 87 could be null and is dereferenced at line 97, column 19.

libavcodec/mpeg12.c:83:1: start of procedure init_2d_vlc_rl()
81. uint8_t ff_mpeg12_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3];
82. 
83. static void init_2d_vlc_rl(RLTable *rl, int use_static)
    ^
84. {
85.     int i;

libavcodec/mpeg12.c:87:5: 
85.     int i;
86. 
87.     init_vlc(&rl->vlc, TEX_VLC_BITS, rl->n + 2,
        ^
88.              &rl->table_vlc[0][1], 4, 2,
89.              &rl->table_vlc[0][0], 4, 2, use_static);

libavcodec/bitstream.c:260:1: start of procedure init_vlc_sparse()
  258.    with av_free_static(), 0 if free_vlc() will be used.
  259. */
  260. int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
       ^
  261.              const void *bits, int bits_wrap, int bits_size,
  262.              const void *codes, int codes_wrap, int codes_size,

libavcodec/bitstream.c:266:5: 
  264.              int flags)
  265. {
  266.     vlc->bits = nb_bits;
           ^
  267.     if(!(flags & INIT_VLC_USE_STATIC)) {
  268.         vlc->table = NULL;

libavcodec/bitstream.c:267:10: Taking true branch
  265. {
  266.     vlc->bits = nb_bits;
  267.     if(!(flags & INIT_VLC_USE_STATIC)) {
                ^
  268.         vlc->table = NULL;
  269.         vlc->table_allocated = 0;

libavcodec/bitstream.c:268:9: 
  266.     vlc->bits = nb_bits;
  267.     if(!(flags & INIT_VLC_USE_STATIC)) {
  268.         vlc->table = NULL;
               ^
  269.         vlc->table_allocated = 0;
  270.         vlc->table_size = 0;

libavcodec/bitstream.c:269:9: 
  267.     if(!(flags & INIT_VLC_USE_STATIC)) {
  268.         vlc->table = NULL;
  269.         vlc->table_allocated = 0;
               ^
  270.         vlc->table_size = 0;
  271.     } else {

libavcodec/bitstream.c:270:9: 
  268.         vlc->table = NULL;
  269.         vlc->table_allocated = 0;
  270.         vlc->table_size = 0;
               ^
  271.     } else {
  272.         /* Static tables are initially always NULL, return

libavcodec/bitstream.c:282:9: Taking true branch
  280. #endif
  281. 
  282.     if (build_table(vlc, nb_bits, nb_codes,
               ^
  283.                     bits, bits_wrap, bits_size,
  284.                     codes, codes_wrap, codes_size,

libavcodec/bitstream.c:287:9: 
  285.                     symbols, symbols_wrap, symbols_size,
  286.                     0, 0, flags) < 0) {
  287.         av_freep(&vlc->table);
               ^
  288.         return -1;
  289.     }

libavutil/mem.c:125:1: start of procedure av_freep()
    123. }
    124. 
    125. void av_freep(void *arg)
         ^
    126. {
    127.     void **ptr= (void**)arg;

libavutil/mem.c:127:5: 
    125. void av_freep(void *arg)
    126. {
    127.     void **ptr= (void**)arg;
             ^
    128.     av_free(*ptr);
    129.     *ptr = NULL;

libavutil/mem.c:128:5: 
    126. {
    127.     void **ptr= (void**)arg;
    128.     av_free(*ptr);
             ^
    129.     *ptr = NULL;
    130. }

libavutil/mem.c:114:1: start of procedure av_free()
      112. }
      113. 
      114. void av_free(void *ptr)
           ^
      115. {
      116.     /* XXX: this test should not be needed on most libcs */

libavutil/mem.c:117:9: Taking false branch
      115. {
      116.     /* XXX: this test should not be needed on most libcs */
      117.     if (ptr)
                   ^
      118. #ifdef CONFIG_MEMALIGN_HACK
      119.         free((char*)ptr - ((char*)ptr)[-1]);

libavutil/mem.c:117:5: 
      115. {
      116.     /* XXX: this test should not be needed on most libcs */
      117.     if (ptr)
               ^
      118. #ifdef CONFIG_MEMALIGN_HACK
      119.         free((char*)ptr - ((char*)ptr)[-1]);

libavutil/mem.c:123:1: return from a call to av_free
      121.         free(ptr);
      122. #endif
      123. }
           ^
      124. 
      125. void av_freep(void *arg)

libavutil/mem.c:129:5: 
    127.     void **ptr= (void**)arg;
    128.     av_free(*ptr);
    129.     *ptr = NULL;
             ^
    130. }
    131. 

libavutil/mem.c:130:1: return from a call to av_freep
    128.     av_free(*ptr);
    129.     *ptr = NULL;
    130. }
         ^
    131. 
    132. void *av_mallocz(unsigned int size)

libavcodec/bitstream.c:288:9: 
  286.                     0, 0, flags) < 0) {
  287.         av_freep(&vlc->table);
  288.         return -1;
               ^
  289.     }
  290.     return 0;

libavcodec/bitstream.c:291:1: return from a call to init_vlc_sparse
  289.     }
  290.     return 0;
  291. }
       ^
  292. 
  293. 

libavcodec/mpeg12.c:91:8: Taking true branch
89.              &rl->table_vlc[0][0], 4, 2, use_static);
90. 
91.     if(use_static)
           ^
92.         rl->rl_vlc[0]= av_mallocz_static(rl->vlc.table_size*sizeof(RL_VLC_ELEM));
93.     else

libavcodec/mpeg12.c:92:9: 
90. 
91.     if(use_static)
92.         rl->rl_vlc[0]= av_mallocz_static(rl->vlc.table_size*sizeof(RL_VLC_ELEM));
            ^
93.     else
94.         rl->rl_vlc[0]= av_malloc(rl->vlc.table_size*sizeof(RL_VLC_ELEM));

libavcodec/utils.c:80:1: start of procedure av_mallocz_static()
  78. static void** array_static = NULL;
  79. 
  80. void *av_mallocz_static(unsigned int size)
      ^
  81. {
  82.     void *ptr = av_mallocz(size);

libavcodec/utils.c:82:5: 
  80. void *av_mallocz_static(unsigned int size)
  81. {
  82.     void *ptr = av_mallocz(size);
          ^
  83. 
  84.     if(ptr){

libavutil/mem.c:132:1: start of procedure av_mallocz()
    130. }
    131. 
    132. void *av_mallocz(unsigned int size)
         ^
    133. {
    134.     void *ptr = av_malloc(size);

libavutil/mem.c:134:5: 
    132. void *av_mallocz(unsigned int size)
    133. {
    134.     void *ptr = av_malloc(size);
             ^
    135.     if (ptr)
    136.         memset(ptr, 0, size);

libavutil/mem.c:42:1: start of procedure av_malloc()
      40.    linker will do it automatically */
      41. 
      42. void *av_malloc(unsigned int size)
          ^
      43. {
      44.     void *ptr;

libavutil/mem.c:50:8: Taking true branch
      48. 
      49.     /* let's disallow possible ambiguous cases */
      50.     if(size > (INT_MAX-16) )
                 ^
      51.         return NULL;
      52. 

libavutil/mem.c:51:9: 
      49.     /* let's disallow possible ambiguous cases */
      50.     if(size > (INT_MAX-16) )
      51.         return NULL;
                  ^
      52. 
      53. #ifdef CONFIG_MEMALIGN_HACK

libavutil/mem.c:92:1: return from a call to av_malloc
      90. #endif
      91.     return ptr;
      92. }
          ^
      93. 
      94. void *av_realloc(void *ptr, unsigned int size)

libavutil/mem.c:135:9: Taking false branch
    133. {
    134.     void *ptr = av_malloc(size);
    135.     if (ptr)
                 ^
    136.         memset(ptr, 0, size);
    137.     return ptr;

libavutil/mem.c:137:5: 
    135.     if (ptr)
    136.         memset(ptr, 0, size);
    137.     return ptr;
             ^
    138. }
    139. 

libavutil/mem.c:138:1: return from a call to av_mallocz
    136.         memset(ptr, 0, size);
    137.     return ptr;
    138. }
         ^
    139. 
    140. char *av_strdup(const char *s)

libavcodec/utils.c:84:8: Taking false branch
  82.     void *ptr = av_mallocz(size);
  83. 
  84.     if(ptr){
             ^
  85.         array_static =av_fast_realloc(array_static, &allocated_static, sizeof(void*)*(last_static+1));
  86.         if(!array_static)

libavcodec/utils.c:91:5: 
  89.     }
  90. 
  91.     return ptr;
          ^
  92. }
  93. 

libavcodec/utils.c:92:1: return from a call to av_mallocz_static
  90. 
  91.     return ptr;
  92. }
      ^
  93. 
  94. void *ff_realloc_static(void *ptr, unsigned int size)

libavcodec/mpeg12.c:96:9: 
94.         rl->rl_vlc[0]= av_malloc(rl->vlc.table_size*sizeof(RL_VLC_ELEM));
95. 
96.     for(i=0; i<rl->vlc.table_size; i++){
            ^
97.         int code= rl->vlc.table[i][0];
98.         int len = rl->vlc.table[i][1];

libavcodec/mpeg12.c:96:14: Loop condition is true. Entering loop body
94.         rl->rl_vlc[0]= av_malloc(rl->vlc.table_size*sizeof(RL_VLC_ELEM));
95. 
96.     for(i=0; i<rl->vlc.table_size; i++){
                 ^
97.         int code= rl->vlc.table[i][0];
98.         int len = rl->vlc.table[i][1];

libavcodec/mpeg12.c:97:9: 
95. 
96.     for(i=0; i<rl->vlc.table_size; i++){
97.         int code= rl->vlc.table[i][0];
            ^
98.         int len = rl->vlc.table[i][1];
99.         int level, run;

static void init_2d_vlc_rl(RLTable *rl, int use_static)
{
    int i;
    init_vlc(&rl->vlc, TEX_VLC_BITS, rl->n + 2,
             &rl->table_vlc[0][1], 4, 2,
             &rl->table_vlc[0][0], 4, 2, use_static);
    if(use_static)
        rl->rl_vlc[0]= av_mallocz_static(rl->vlc.table_size*sizeof(RL_VLC_ELEM));
    else
        rl->rl_vlc[0]= av_malloc(rl->vlc.table_size*sizeof(RL_VLC_ELEM));
    for(i=0; i<rl->vlc.table_size; i++){
        int code= rl->vlc.table[i][0];
        int len = rl->vlc.table[i][1];
        int level, run;
        if(len==0){
            run= 65;
            level= MAX_LEVEL;
        }else if(len<0){
            run= 0;
            level= code;
        }else{
            if(code==rl->n){
                run= 65;
                level= 0;
            }else if(code==rl->n+1){
                run= 0;
                level= 127;
            }else{
                run=   rl->table_run  [code] + 1;
                level= rl->table_level[code];
            }
        }
        rl->rl_vlc[0][i].len= len;
        rl->rl_vlc[0][i].level= level;
        rl->rl_vlc[0][i].run= run;
    }
}
['static void init_2d_vlc_rl(RLTable *rl, int use_static)\n{\n    int i;\n    init_vlc(&rl->vlc, TEX_VLC_BITS, rl->n + 2,\n             &rl->table_vlc[0][1], 4, 2,\n             &rl->table_vlc[0][0], 4, 2, use_static);\n    if(use_static)\n        rl->rl_vlc[0]= av_mallocz_static(rl->vlc.table_size*sizeof(RL_VLC_ELEM));\n    else\n        rl->rl_vlc[0]= av_malloc(rl->vlc.table_size*sizeof(RL_VLC_ELEM));\n    for(i=0; i<rl->vlc.table_size; i++){\n        int code= rl->vlc.table[i][0];\n        int len = rl->vlc.table[i][1];\n        int level, run;\n        if(len==0){\n            run= 65;\n            level= MAX_LEVEL;\n        }else if(len<0){\n            run= 0;\n            level= code;\n        }else{\n            if(code==rl->n){\n                run= 65;\n                level= 0;\n            }else if(code==rl->n+1){\n                run= 0;\n                level= 127;\n            }else{\n                run=   rl->table_run  [code] + 1;\n                level= rl->table_level[code];\n            }\n        }\n        rl->rl_vlc[0][i].len= len;\n        rl->rl_vlc[0][i].level= level;\n        rl->rl_vlc[0][i].run= run;\n    }\n}', 'int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,\n             const void *bits, int bits_wrap, int bits_size,\n             const void *codes, int codes_wrap, int codes_size,\n             const void *symbols, int symbols_wrap, int symbols_size,\n             int flags)\n{\n    vlc->bits = nb_bits;\n    if(!(flags & INIT_VLC_USE_STATIC)) {\n        vlc->table = NULL;\n        vlc->table_allocated = 0;\n        vlc->table_size = 0;\n    } else {\n        if(vlc->table)\n            return 0;\n    }\n#ifdef DEBUG_VLC\n    av_log(NULL,AV_LOG_DEBUG,"build table nb_codes=%d\\n", nb_codes);\n#endif\n    if (build_table(vlc, nb_bits, nb_codes,\n                    bits, bits_wrap, bits_size,\n                    codes, codes_wrap, codes_size,\n                    symbols, symbols_wrap, symbols_size,\n                    0, 0, flags) < 0) {\n        av_freep(&vlc->table);\n        return -1;\n    }\n    return 0;\n}', 'void av_freep(void *arg)\n{\n    void **ptr= (void**)arg;\n    av_free(*ptr);\n    *ptr = NULL;\n}', 'void av_free(void *ptr)\n{\n    if (ptr)\n#ifdef CONFIG_MEMALIGN_HACK\n        free((char*)ptr - ((char*)ptr)[-1]);\n#else\n        free(ptr);\n#endif\n}', 'void *av_mallocz_static(unsigned int size)\n{\n    void *ptr = av_mallocz(size);\n    if(ptr){\n        array_static =av_fast_realloc(array_static, &allocated_static, sizeof(void*)*(last_static+1));\n        if(!array_static)\n            return NULL;\n        array_static[last_static++] = ptr;\n    }\n    return ptr;\n}', 'void *av_mallocz(unsigned int size)\n{\n    void *ptr = av_malloc(size);\n    if (ptr)\n        memset(ptr, 0, size);\n    return ptr;\n}', 'void *av_malloc(unsigned int size)\n{\n    void *ptr;\n#ifdef CONFIG_MEMALIGN_HACK\n    long diff;\n#endif\n    if(size > (INT_MAX-16) )\n        return NULL;\n#ifdef CONFIG_MEMALIGN_HACK\n    ptr = malloc(size+16);\n    if(!ptr)\n        return ptr;\n    diff= ((-(long)ptr - 1)&15) + 1;\n    ptr = (char*)ptr + diff;\n    ((char*)ptr)[-1]= diff;\n#elif defined (HAVE_MEMALIGN)\n    ptr = memalign(16,size);\n#else\n    ptr = malloc(size);\n#endif\n    return ptr;\n}']