libavcodec/smacker.c:297: error: Null Dereference
  pointer `smk->mclr_tbl` last assigned on line 296 could be null and is dereferenced at line 297, column 9.

libavcodec/smacker.c:275:1: start of procedure decode_header_trees()
273. }
274. 
275. static int decode_header_trees(SmackVContext *smk) {
     ^
276.     GetBitContext gb;
277.     int mmap_size, mclr_size, full_size, type_size;

libavcodec/smacker.c:279:5: 
277.     int mmap_size, mclr_size, full_size, type_size;
278. 
279.     mmap_size = AV_RL32(smk->avctx->extradata);
         ^
280.     mclr_size = AV_RL32(smk->avctx->extradata + 4);
281.     full_size = AV_RL32(smk->avctx->extradata + 8);

libavcodec/smacker.c:280:5: 
278. 
279.     mmap_size = AV_RL32(smk->avctx->extradata);
280.     mclr_size = AV_RL32(smk->avctx->extradata + 4);
         ^
281.     full_size = AV_RL32(smk->avctx->extradata + 8);
282.     type_size = AV_RL32(smk->avctx->extradata + 12);

libavcodec/smacker.c:281:5: 
279.     mmap_size = AV_RL32(smk->avctx->extradata);
280.     mclr_size = AV_RL32(smk->avctx->extradata + 4);
281.     full_size = AV_RL32(smk->avctx->extradata + 8);
         ^
282.     type_size = AV_RL32(smk->avctx->extradata + 12);
283. 

libavcodec/smacker.c:282:5: 
280.     mclr_size = AV_RL32(smk->avctx->extradata + 4);
281.     full_size = AV_RL32(smk->avctx->extradata + 8);
282.     type_size = AV_RL32(smk->avctx->extradata + 12);
         ^
283. 
284.     init_get_bits(&gb, smk->avctx->extradata + 16, (smk->avctx->extradata_size - 16) * 8);

libavcodec/smacker.c:284:5: 
282.     type_size = AV_RL32(smk->avctx->extradata + 12);
283. 
284.     init_get_bits(&gb, smk->avctx->extradata + 16, (smk->avctx->extradata_size - 16) * 8);
         ^
285. 
286.     if(!get_bits1(&gb)) {

libavcodec/get_bits.h:473:1: start of procedure init_get_bits()
  471.  * responsible for checking for the buffer end yourself (take advantage of the padding)!
  472.  */
  473. static inline void init_get_bits(GetBitContext *s,
       ^
  474.                    const uint8_t *buffer, int bit_size)
  475. {

libavcodec/get_bits.h:476:5: 
  474.                    const uint8_t *buffer, int bit_size)
  475. {
  476.     int buffer_size= (bit_size+7)>>3;
           ^
  477.     if(buffer_size < 0 || bit_size < 0) {
  478.         buffer_size = bit_size = 0;

libavcodec/get_bits.h:477:8: Taking false branch
  475. {
  476.     int buffer_size= (bit_size+7)>>3;
  477.     if(buffer_size < 0 || bit_size < 0) {
              ^
  478.         buffer_size = bit_size = 0;
  479.         buffer = NULL;

libavcodec/get_bits.h:477:27: Taking false branch
  475. {
  476.     int buffer_size= (bit_size+7)>>3;
  477.     if(buffer_size < 0 || bit_size < 0) {
                                 ^
  478.         buffer_size = bit_size = 0;
  479.         buffer = NULL;

libavcodec/get_bits.h:482:5: 
  480.     }
  481. 
  482.     s->buffer= buffer;
           ^
  483.     s->size_in_bits= bit_size;
  484.     s->buffer_end= buffer + buffer_size;

libavcodec/get_bits.h:483:5: 
  481. 
  482.     s->buffer= buffer;
  483.     s->size_in_bits= bit_size;
           ^
  484.     s->buffer_end= buffer + buffer_size;
  485. #ifdef ALT_BITSTREAM_READER

libavcodec/get_bits.h:484:5: 
  482.     s->buffer= buffer;
  483.     s->size_in_bits= bit_size;
  484.     s->buffer_end= buffer + buffer_size;
           ^
  485. #ifdef ALT_BITSTREAM_READER
  486.     s->index=0;

libavcodec/get_bits.h:486:5: 
  484.     s->buffer_end= buffer + buffer_size;
  485. #ifdef ALT_BITSTREAM_READER
  486.     s->index=0;
           ^
  487. #elif defined LIBMPEG2_BITSTREAM_READER
  488.     s->buffer_ptr = (uint8_t*)((intptr_t)buffer&(~1));

libavcodec/get_bits.h:496:1: return from a call to init_get_bits
  494.     skip_bits_long(s, 0);
  495. #endif
  496. }
       ^
  497. 
  498. static inline void align_get_bits(GetBitContext *s)

libavcodec/smacker.c:286:9: 
284.     init_get_bits(&gb, smk->avctx->extradata + 16, (smk->avctx->extradata_size - 16) * 8);
285. 
286.     if(!get_bits1(&gb)) {
             ^
287.         av_log(smk->avctx, AV_LOG_INFO, "Skipping MMAP tree\n");
288.         smk->mmap_tbl = av_malloc(sizeof(int) * 2);

libavcodec/get_bits.h:393:1: start of procedure get_bits1()
  391. }
  392. 
  393. static inline unsigned int get_bits1(GetBitContext *s){
       ^
  394. #ifdef ALT_BITSTREAM_READER
  395.     unsigned int index= s->index;

libavcodec/get_bits.h:395:5: 
  393. static inline unsigned int get_bits1(GetBitContext *s){
  394. #ifdef ALT_BITSTREAM_READER
  395.     unsigned int index= s->index;
           ^
  396.     uint8_t result= s->buffer[ index>>3 ];
  397. #ifdef ALT_BITSTREAM_READER_LE

libavcodec/get_bits.h:396:5: 
  394. #ifdef ALT_BITSTREAM_READER
  395.     unsigned int index= s->index;
  396.     uint8_t result= s->buffer[ index>>3 ];
           ^
  397. #ifdef ALT_BITSTREAM_READER_LE
  398.     result>>= (index&0x07);

libavcodec/get_bits.h:398:5: 
  396.     uint8_t result= s->buffer[ index>>3 ];
  397. #ifdef ALT_BITSTREAM_READER_LE
  398.     result>>= (index&0x07);
           ^
  399.     result&= 1;
  400. #else

libavcodec/get_bits.h:399:5: 
  397. #ifdef ALT_BITSTREAM_READER_LE
  398.     result>>= (index&0x07);
  399.     result&= 1;
           ^
  400. #else
  401.     result<<= (index&0x07);

libavcodec/get_bits.h:404:5: 
  402.     result>>= 8 - 1;
  403. #endif
  404.     index++;
           ^
  405.     s->index= index;
  406. 

libavcodec/get_bits.h:405:5: 
  403. #endif
  404.     index++;
  405.     s->index= index;
           ^
  406. 
  407.     return result;

libavcodec/get_bits.h:407:5: 
  405.     s->index= index;
  406. 
  407.     return result;
           ^
  408. #else
  409.     return get_bits(s, 1);

libavcodec/get_bits.h:411:1: return from a call to get_bits1
  409.     return get_bits(s, 1);
  410. #endif
  411. }
       ^
  412. 
  413. static inline unsigned int show_bits1(GetBitContext *s){

libavcodec/smacker.c:286:9: Taking true branch
284.     init_get_bits(&gb, smk->avctx->extradata + 16, (smk->avctx->extradata_size - 16) * 8);
285. 
286.     if(!get_bits1(&gb)) {
             ^
287.         av_log(smk->avctx, AV_LOG_INFO, "Skipping MMAP tree\n");
288.         smk->mmap_tbl = av_malloc(sizeof(int) * 2);

libavcodec/smacker.c:287:9: Skipping av_log(): empty list of specs
285. 
286.     if(!get_bits1(&gb)) {
287.         av_log(smk->avctx, AV_LOG_INFO, "Skipping MMAP tree\n");
             ^
288.         smk->mmap_tbl = av_malloc(sizeof(int) * 2);
289.         smk->mmap_tbl[0] = 0;

libavcodec/smacker.c:288:9: 
286.     if(!get_bits1(&gb)) {
287.         av_log(smk->avctx, AV_LOG_INFO, "Skipping MMAP tree\n");
288.         smk->mmap_tbl = av_malloc(sizeof(int) * 2);
             ^
289.         smk->mmap_tbl[0] = 0;
290.         smk->mmap_last[0] = smk->mmap_last[1] = smk->mmap_last[2] = 1;

libavutil/mem.c:64:1: start of procedure av_malloc()
  62.    linker will do it automatically. */
  63. 
  64. void *av_malloc(FF_INTERNAL_MEM_TYPE size)
      ^
  65. {
  66.     void *ptr = NULL;

libavutil/mem.c:66:5: 
  64. void *av_malloc(FF_INTERNAL_MEM_TYPE size)
  65. {
  66.     void *ptr = NULL;
          ^
  67. #if CONFIG_MEMALIGN_HACK
  68.     long diff;

libavutil/mem.c:72:8: Taking false branch
  70. 
  71.     /* let's disallow possible ambiguous cases */
  72.     if(size > (INT_MAX-16) )
             ^
  73.         return NULL;
  74. 

libavutil/mem.c:83:9: Taking false branch
  81.     ((char*)ptr)[-1]= diff;
  82. #elif HAVE_POSIX_MEMALIGN
  83.     if (posix_memalign(&ptr,16,size))
              ^
  84.         ptr = NULL;
  85. #elif HAVE_MEMALIGN

libavutil/mem.c:116:5: 
  114.     ptr = malloc(size);
  115. #endif
  116.     return ptr;
           ^
  117. }
  118. 

libavutil/mem.c:117:1: return from a call to av_malloc
  115. #endif
  116.     return ptr;
  117. }
       ^
  118. 
  119. void *av_realloc(void *ptr, FF_INTERNAL_MEM_TYPE size)

libavcodec/smacker.c:289:9: 
287.         av_log(smk->avctx, AV_LOG_INFO, "Skipping MMAP tree\n");
288.         smk->mmap_tbl = av_malloc(sizeof(int) * 2);
289.         smk->mmap_tbl[0] = 0;
             ^
290.         smk->mmap_last[0] = smk->mmap_last[1] = smk->mmap_last[2] = 1;
291.     } else {

libavcodec/smacker.c:290:9: 
288.         smk->mmap_tbl = av_malloc(sizeof(int) * 2);
289.         smk->mmap_tbl[0] = 0;
290.         smk->mmap_last[0] = smk->mmap_last[1] = smk->mmap_last[2] = 1;
             ^
291.     } else {
292.         smacker_decode_header_tree(smk, &gb, &smk->mmap_tbl, smk->mmap_last, mmap_size);

libavcodec/smacker.c:294:9: 
292.         smacker_decode_header_tree(smk, &gb, &smk->mmap_tbl, smk->mmap_last, mmap_size);
293.     }
294.     if(!get_bits1(&gb)) {
             ^
295.         av_log(smk->avctx, AV_LOG_INFO, "Skipping MCLR tree\n");
296.         smk->mclr_tbl = av_malloc(sizeof(int) * 2);

libavcodec/get_bits.h:393:1: start of procedure get_bits1()
  391. }
  392. 
  393. static inline unsigned int get_bits1(GetBitContext *s){
       ^
  394. #ifdef ALT_BITSTREAM_READER
  395.     unsigned int index= s->index;

libavcodec/get_bits.h:395:5: 
  393. static inline unsigned int get_bits1(GetBitContext *s){
  394. #ifdef ALT_BITSTREAM_READER
  395.     unsigned int index= s->index;
           ^
  396.     uint8_t result= s->buffer[ index>>3 ];
  397. #ifdef ALT_BITSTREAM_READER_LE

libavcodec/get_bits.h:396:5: 
  394. #ifdef ALT_BITSTREAM_READER
  395.     unsigned int index= s->index;
  396.     uint8_t result= s->buffer[ index>>3 ];
           ^
  397. #ifdef ALT_BITSTREAM_READER_LE
  398.     result>>= (index&0x07);

libavcodec/get_bits.h:398:5: 
  396.     uint8_t result= s->buffer[ index>>3 ];
  397. #ifdef ALT_BITSTREAM_READER_LE
  398.     result>>= (index&0x07);
           ^
  399.     result&= 1;
  400. #else

libavcodec/get_bits.h:399:5: 
  397. #ifdef ALT_BITSTREAM_READER_LE
  398.     result>>= (index&0x07);
  399.     result&= 1;
           ^
  400. #else
  401.     result<<= (index&0x07);

libavcodec/get_bits.h:404:5: 
  402.     result>>= 8 - 1;
  403. #endif
  404.     index++;
           ^
  405.     s->index= index;
  406. 

libavcodec/get_bits.h:405:5: 
  403. #endif
  404.     index++;
  405.     s->index= index;
           ^
  406. 
  407.     return result;

libavcodec/get_bits.h:407:5: 
  405.     s->index= index;
  406. 
  407.     return result;
           ^
  408. #else
  409.     return get_bits(s, 1);

libavcodec/get_bits.h:411:1: return from a call to get_bits1
  409.     return get_bits(s, 1);
  410. #endif
  411. }
       ^
  412. 
  413. static inline unsigned int show_bits1(GetBitContext *s){

libavcodec/smacker.c:294:9: Taking true branch
292.         smacker_decode_header_tree(smk, &gb, &smk->mmap_tbl, smk->mmap_last, mmap_size);
293.     }
294.     if(!get_bits1(&gb)) {
             ^
295.         av_log(smk->avctx, AV_LOG_INFO, "Skipping MCLR tree\n");
296.         smk->mclr_tbl = av_malloc(sizeof(int) * 2);

libavcodec/smacker.c:295:9: Skipping av_log(): empty list of specs
293.     }
294.     if(!get_bits1(&gb)) {
295.         av_log(smk->avctx, AV_LOG_INFO, "Skipping MCLR tree\n");
             ^
296.         smk->mclr_tbl = av_malloc(sizeof(int) * 2);
297.         smk->mclr_tbl[0] = 0;

libavcodec/smacker.c:296:9: 
294.     if(!get_bits1(&gb)) {
295.         av_log(smk->avctx, AV_LOG_INFO, "Skipping MCLR tree\n");
296.         smk->mclr_tbl = av_malloc(sizeof(int) * 2);
             ^
297.         smk->mclr_tbl[0] = 0;
298.         smk->mclr_last[0] = smk->mclr_last[1] = smk->mclr_last[2] = 1;

libavutil/mem.c:64:1: start of procedure av_malloc()
  62.    linker will do it automatically. */
  63. 
  64. void *av_malloc(FF_INTERNAL_MEM_TYPE size)
      ^
  65. {
  66.     void *ptr = NULL;

libavutil/mem.c:66:5: 
  64. void *av_malloc(FF_INTERNAL_MEM_TYPE size)
  65. {
  66.     void *ptr = NULL;
          ^
  67. #if CONFIG_MEMALIGN_HACK
  68.     long diff;

libavutil/mem.c:72:8: Taking false branch
  70. 
  71.     /* let's disallow possible ambiguous cases */
  72.     if(size > (INT_MAX-16) )
             ^
  73.         return NULL;
  74. 

libavutil/mem.c:83:9: Taking true branch
  81.     ((char*)ptr)[-1]= diff;
  82. #elif HAVE_POSIX_MEMALIGN
  83.     if (posix_memalign(&ptr,16,size))
              ^
  84.         ptr = NULL;
  85. #elif HAVE_MEMALIGN

libavutil/mem.c:84:9: 
  82. #elif HAVE_POSIX_MEMALIGN
  83.     if (posix_memalign(&ptr,16,size))
  84.         ptr = NULL;
              ^
  85. #elif HAVE_MEMALIGN
  86.     ptr = memalign(16,size);

libavutil/mem.c:116:5: 
  114.     ptr = malloc(size);
  115. #endif
  116.     return ptr;
           ^
  117. }
  118. 

libavutil/mem.c:117:1: return from a call to av_malloc
  115. #endif
  116.     return ptr;
  117. }
       ^
  118. 
  119. void *av_realloc(void *ptr, FF_INTERNAL_MEM_TYPE size)

libavcodec/smacker.c:297:9: 
295.         av_log(smk->avctx, AV_LOG_INFO, "Skipping MCLR tree\n");
296.         smk->mclr_tbl = av_malloc(sizeof(int) * 2);
297.         smk->mclr_tbl[0] = 0;
             ^
298.         smk->mclr_last[0] = smk->mclr_last[1] = smk->mclr_last[2] = 1;
299.     } else {

static int decode_header_trees(SmackVContext *smk) {
    GetBitContext gb;
    int mmap_size, mclr_size, full_size, type_size;
    mmap_size = AV_RL32(smk->avctx->extradata);
    mclr_size = AV_RL32(smk->avctx->extradata + 4);
    full_size = AV_RL32(smk->avctx->extradata + 8);
    type_size = AV_RL32(smk->avctx->extradata + 12);
    init_get_bits(&gb, smk->avctx->extradata + 16, (smk->avctx->extradata_size - 16) * 8);
    if(!get_bits1(&gb)) {
        av_log(smk->avctx, AV_LOG_INFO, "Skipping MMAP tree\n");
        smk->mmap_tbl = av_malloc(sizeof(int) * 2);
        smk->mmap_tbl[0] = 0;
        smk->mmap_last[0] = smk->mmap_last[1] = smk->mmap_last[2] = 1;
    } else {
        smacker_decode_header_tree(smk, &gb, &smk->mmap_tbl, smk->mmap_last, mmap_size);
    }
    if(!get_bits1(&gb)) {
        av_log(smk->avctx, AV_LOG_INFO, "Skipping MCLR tree\n");
        smk->mclr_tbl = av_malloc(sizeof(int) * 2);
        smk->mclr_tbl[0] = 0;
        smk->mclr_last[0] = smk->mclr_last[1] = smk->mclr_last[2] = 1;
    } else {
        smacker_decode_header_tree(smk, &gb, &smk->mclr_tbl, smk->mclr_last, mclr_size);
    }
    if(!get_bits1(&gb)) {
        av_log(smk->avctx, AV_LOG_INFO, "Skipping FULL tree\n");
        smk->full_tbl = av_malloc(sizeof(int) * 2);
        smk->full_tbl[0] = 0;
        smk->full_last[0] = smk->full_last[1] = smk->full_last[2] = 1;
    } else {
        smacker_decode_header_tree(smk, &gb, &smk->full_tbl, smk->full_last, full_size);
    }
    if(!get_bits1(&gb)) {
        av_log(smk->avctx, AV_LOG_INFO, "Skipping TYPE tree\n");
        smk->type_tbl = av_malloc(sizeof(int) * 2);
        smk->type_tbl[0] = 0;
        smk->type_last[0] = smk->type_last[1] = smk->type_last[2] = 1;
    } else {
        smacker_decode_header_tree(smk, &gb, &smk->type_tbl, smk->type_last, type_size);
    }
    return 0;
}
['static int decode_header_trees(SmackVContext *smk) {\n    GetBitContext gb;\n    int mmap_size, mclr_size, full_size, type_size;\n    mmap_size = AV_RL32(smk->avctx->extradata);\n    mclr_size = AV_RL32(smk->avctx->extradata + 4);\n    full_size = AV_RL32(smk->avctx->extradata + 8);\n    type_size = AV_RL32(smk->avctx->extradata + 12);\n    init_get_bits(&gb, smk->avctx->extradata + 16, (smk->avctx->extradata_size - 16) * 8);\n    if(!get_bits1(&gb)) {\n        av_log(smk->avctx, AV_LOG_INFO, "Skipping MMAP tree\\n");\n        smk->mmap_tbl = av_malloc(sizeof(int) * 2);\n        smk->mmap_tbl[0] = 0;\n        smk->mmap_last[0] = smk->mmap_last[1] = smk->mmap_last[2] = 1;\n    } else {\n        smacker_decode_header_tree(smk, &gb, &smk->mmap_tbl, smk->mmap_last, mmap_size);\n    }\n    if(!get_bits1(&gb)) {\n        av_log(smk->avctx, AV_LOG_INFO, "Skipping MCLR tree\\n");\n        smk->mclr_tbl = av_malloc(sizeof(int) * 2);\n        smk->mclr_tbl[0] = 0;\n        smk->mclr_last[0] = smk->mclr_last[1] = smk->mclr_last[2] = 1;\n    } else {\n        smacker_decode_header_tree(smk, &gb, &smk->mclr_tbl, smk->mclr_last, mclr_size);\n    }\n    if(!get_bits1(&gb)) {\n        av_log(smk->avctx, AV_LOG_INFO, "Skipping FULL tree\\n");\n        smk->full_tbl = av_malloc(sizeof(int) * 2);\n        smk->full_tbl[0] = 0;\n        smk->full_last[0] = smk->full_last[1] = smk->full_last[2] = 1;\n    } else {\n        smacker_decode_header_tree(smk, &gb, &smk->full_tbl, smk->full_last, full_size);\n    }\n    if(!get_bits1(&gb)) {\n        av_log(smk->avctx, AV_LOG_INFO, "Skipping TYPE tree\\n");\n        smk->type_tbl = av_malloc(sizeof(int) * 2);\n        smk->type_tbl[0] = 0;\n        smk->type_last[0] = smk->type_last[1] = smk->type_last[2] = 1;\n    } else {\n        smacker_decode_header_tree(smk, &gb, &smk->type_tbl, smk->type_last, type_size);\n    }\n    return 0;\n}', 'static inline void init_get_bits(GetBitContext *s,\n                   const uint8_t *buffer, int bit_size)\n{\n    int buffer_size= (bit_size+7)>>3;\n    if(buffer_size < 0 || bit_size < 0) {\n        buffer_size = bit_size = 0;\n        buffer = NULL;\n    }\n    s->buffer= buffer;\n    s->size_in_bits= bit_size;\n    s->buffer_end= buffer + buffer_size;\n#ifdef ALT_BITSTREAM_READER\n    s->index=0;\n#elif defined LIBMPEG2_BITSTREAM_READER\n    s->buffer_ptr = (uint8_t*)((intptr_t)buffer&(~1));\n    s->bit_count = 16 + 8*((intptr_t)buffer&1);\n    skip_bits_long(s, 0);\n#elif defined A32_BITSTREAM_READER\n    s->buffer_ptr = (uint32_t*)((intptr_t)buffer&(~3));\n    s->bit_count = 32 + 8*((intptr_t)buffer&3);\n    skip_bits_long(s, 0);\n#endif\n}', 'static inline unsigned int get_bits1(GetBitContext *s){\n#ifdef ALT_BITSTREAM_READER\n    unsigned int index= s->index;\n    uint8_t result= s->buffer[ index>>3 ];\n#ifdef ALT_BITSTREAM_READER_LE\n    result>>= (index&0x07);\n    result&= 1;\n#else\n    result<<= (index&0x07);\n    result>>= 8 - 1;\n#endif\n    index++;\n    s->index= index;\n    return result;\n#else\n    return get_bits(s, 1);\n#endif\n}', 'void *av_malloc(FF_INTERNAL_MEM_TYPE size)\n{\n    void *ptr = NULL;\n#if CONFIG_MEMALIGN_HACK\n    long diff;\n#endif\n    if(size > (INT_MAX-16) )\n        return NULL;\n#if 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 HAVE_POSIX_MEMALIGN\n    if (posix_memalign(&ptr,16,size))\n        ptr = NULL;\n#elif HAVE_MEMALIGN\n    ptr = memalign(16,size);\n#else\n    ptr = malloc(size);\n#endif\n    return ptr;\n}']