libavcodec/truemotion2.c:149: error: Null Dereference
  pointer `&huff->bits` last assigned on line 146 could be null and is dereferenced by call to `tm2_read_tree()` at line 149, column 8.

libavcodec/truemotion2.c:117:1: start of procedure tm2_build_huff_table()
115. }
116. 
117. static int tm2_build_huff_table(TM2Context *ctx, TM2Codes *code)
     ^
118. {
119.     TM2Huff huff;

libavcodec/truemotion2.c:120:5: 
118. {
119.     TM2Huff huff;
120.     int res = 0;
         ^
121. 
122.     huff.val_bits = get_bits(&ctx->gb, 5);

libavcodec/truemotion2.c:122:5: 
120.     int res = 0;
121. 
122.     huff.val_bits = get_bits(&ctx->gb, 5);
         ^
123.     huff.max_bits = get_bits(&ctx->gb, 5);
124.     huff.min_bits = get_bits(&ctx->gb, 5);

libavcodec/get_bits.h:230:1: start of procedure get_bits()
  228.  * Read 1-25 bits.
  229.  */
  230. static inline unsigned int get_bits(GetBitContext *s, int n){
       ^
  231.     register int tmp;
  232.     OPEN_READER(re, s);

libavcodec/get_bits.h:232:5: 
  230. static inline unsigned int get_bits(GetBitContext *s, int n){
  231.     register int tmp;
  232.     OPEN_READER(re, s);
           ^
  233.     UPDATE_CACHE(re, s);
  234.     tmp = SHOW_UBITS(re, s, n);

libavcodec/get_bits.h:233:5: 
  231.     register int tmp;
  232.     OPEN_READER(re, s);
  233.     UPDATE_CACHE(re, s);
           ^
  234.     tmp = SHOW_UBITS(re, s, n);
  235.     LAST_SKIP_BITS(re, s, n);

libavutil/bswap.h:66:1: start of procedure av_bswap32()
    64. 
    65. #ifndef av_bswap32
    66. static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
        ^
    67. {
    68.     return AV_BSWAP32C(x);

libavutil/bswap.h:68:5: 
    66. static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
    67. {
    68.     return AV_BSWAP32C(x);
            ^
    69. }
    70. #endif

libavutil/bswap.h:69:1: return from a call to av_bswap32
    67. {
    68.     return AV_BSWAP32C(x);
    69. }
        ^
    70. #endif
    71. 

libavcodec/get_bits.h:234:5: 
  232.     OPEN_READER(re, s);
  233.     UPDATE_CACHE(re, s);
  234.     tmp = SHOW_UBITS(re, s, n);
           ^
  235.     LAST_SKIP_BITS(re, s, n);
  236.     CLOSE_READER(re, s);

libavcodec/get_bits.h:235:5: Condition is true
  233.     UPDATE_CACHE(re, s);
  234.     tmp = SHOW_UBITS(re, s, n);
  235.     LAST_SKIP_BITS(re, s, n);
           ^
  236.     CLOSE_READER(re, s);
  237.     return tmp;

libavcodec/get_bits.h:236:5: 
  234.     tmp = SHOW_UBITS(re, s, n);
  235.     LAST_SKIP_BITS(re, s, n);
  236.     CLOSE_READER(re, s);
           ^
  237.     return tmp;
  238. }

libavcodec/get_bits.h:237:5: 
  235.     LAST_SKIP_BITS(re, s, n);
  236.     CLOSE_READER(re, s);
  237.     return tmp;
           ^
  238. }
  239. 

libavcodec/get_bits.h:238:1: return from a call to get_bits
  236.     CLOSE_READER(re, s);
  237.     return tmp;
  238. }
       ^
  239. 
  240. /**

libavcodec/truemotion2.c:123:5: 
121. 
122.     huff.val_bits = get_bits(&ctx->gb, 5);
123.     huff.max_bits = get_bits(&ctx->gb, 5);
         ^
124.     huff.min_bits = get_bits(&ctx->gb, 5);
125.     huff.nodes = get_bits_long(&ctx->gb, 17);

libavcodec/get_bits.h:230:1: start of procedure get_bits()
  228.  * Read 1-25 bits.
  229.  */
  230. static inline unsigned int get_bits(GetBitContext *s, int n){
       ^
  231.     register int tmp;
  232.     OPEN_READER(re, s);

libavcodec/get_bits.h:232:5: 
  230. static inline unsigned int get_bits(GetBitContext *s, int n){
  231.     register int tmp;
  232.     OPEN_READER(re, s);
           ^
  233.     UPDATE_CACHE(re, s);
  234.     tmp = SHOW_UBITS(re, s, n);

libavcodec/get_bits.h:233:5: 
  231.     register int tmp;
  232.     OPEN_READER(re, s);
  233.     UPDATE_CACHE(re, s);
           ^
  234.     tmp = SHOW_UBITS(re, s, n);
  235.     LAST_SKIP_BITS(re, s, n);

libavutil/bswap.h:66:1: start of procedure av_bswap32()
    64. 
    65. #ifndef av_bswap32
    66. static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
        ^
    67. {
    68.     return AV_BSWAP32C(x);

libavutil/bswap.h:68:5: 
    66. static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
    67. {
    68.     return AV_BSWAP32C(x);
            ^
    69. }
    70. #endif

libavutil/bswap.h:69:1: return from a call to av_bswap32
    67. {
    68.     return AV_BSWAP32C(x);
    69. }
        ^
    70. #endif
    71. 

libavcodec/get_bits.h:234:5: 
  232.     OPEN_READER(re, s);
  233.     UPDATE_CACHE(re, s);
  234.     tmp = SHOW_UBITS(re, s, n);
           ^
  235.     LAST_SKIP_BITS(re, s, n);
  236.     CLOSE_READER(re, s);

libavcodec/get_bits.h:235:5: Condition is true
  233.     UPDATE_CACHE(re, s);
  234.     tmp = SHOW_UBITS(re, s, n);
  235.     LAST_SKIP_BITS(re, s, n);
           ^
  236.     CLOSE_READER(re, s);
  237.     return tmp;

libavcodec/get_bits.h:236:5: 
  234.     tmp = SHOW_UBITS(re, s, n);
  235.     LAST_SKIP_BITS(re, s, n);
  236.     CLOSE_READER(re, s);
           ^
  237.     return tmp;
  238. }

libavcodec/get_bits.h:237:5: 
  235.     LAST_SKIP_BITS(re, s, n);
  236.     CLOSE_READER(re, s);
  237.     return tmp;
           ^
  238. }
  239. 

libavcodec/get_bits.h:238:1: return from a call to get_bits
  236.     CLOSE_READER(re, s);
  237.     return tmp;
  238. }
       ^
  239. 
  240. /**

libavcodec/truemotion2.c:124:5: 
122.     huff.val_bits = get_bits(&ctx->gb, 5);
123.     huff.max_bits = get_bits(&ctx->gb, 5);
124.     huff.min_bits = get_bits(&ctx->gb, 5);
         ^
125.     huff.nodes = get_bits_long(&ctx->gb, 17);
126.     huff.num = 0;

libavcodec/get_bits.h:230:1: start of procedure get_bits()
  228.  * Read 1-25 bits.
  229.  */
  230. static inline unsigned int get_bits(GetBitContext *s, int n){
       ^
  231.     register int tmp;
  232.     OPEN_READER(re, s);

libavcodec/get_bits.h:232:5: 
  230. static inline unsigned int get_bits(GetBitContext *s, int n){
  231.     register int tmp;
  232.     OPEN_READER(re, s);
           ^
  233.     UPDATE_CACHE(re, s);
  234.     tmp = SHOW_UBITS(re, s, n);

libavcodec/get_bits.h:233:5: 
  231.     register int tmp;
  232.     OPEN_READER(re, s);
  233.     UPDATE_CACHE(re, s);
           ^
  234.     tmp = SHOW_UBITS(re, s, n);
  235.     LAST_SKIP_BITS(re, s, n);

libavutil/bswap.h:66:1: start of procedure av_bswap32()
    64. 
    65. #ifndef av_bswap32
    66. static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
        ^
    67. {
    68.     return AV_BSWAP32C(x);

libavutil/bswap.h:68:5: 
    66. static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
    67. {
    68.     return AV_BSWAP32C(x);
            ^
    69. }
    70. #endif

libavutil/bswap.h:69:1: return from a call to av_bswap32
    67. {
    68.     return AV_BSWAP32C(x);
    69. }
        ^
    70. #endif
    71. 

libavcodec/get_bits.h:234:5: 
  232.     OPEN_READER(re, s);
  233.     UPDATE_CACHE(re, s);
  234.     tmp = SHOW_UBITS(re, s, n);
           ^
  235.     LAST_SKIP_BITS(re, s, n);
  236.     CLOSE_READER(re, s);

libavcodec/get_bits.h:235:5: Condition is true
  233.     UPDATE_CACHE(re, s);
  234.     tmp = SHOW_UBITS(re, s, n);
  235.     LAST_SKIP_BITS(re, s, n);
           ^
  236.     CLOSE_READER(re, s);
  237.     return tmp;

libavcodec/get_bits.h:236:5: 
  234.     tmp = SHOW_UBITS(re, s, n);
  235.     LAST_SKIP_BITS(re, s, n);
  236.     CLOSE_READER(re, s);
           ^
  237.     return tmp;
  238. }

libavcodec/get_bits.h:237:5: 
  235.     LAST_SKIP_BITS(re, s, n);
  236.     CLOSE_READER(re, s);
  237.     return tmp;
           ^
  238. }
  239. 

libavcodec/get_bits.h:238:1: return from a call to get_bits
  236.     CLOSE_READER(re, s);
  237.     return tmp;
  238. }
       ^
  239. 
  240. /**

libavcodec/truemotion2.c:125:5: 
123.     huff.max_bits = get_bits(&ctx->gb, 5);
124.     huff.min_bits = get_bits(&ctx->gb, 5);
125.     huff.nodes = get_bits_long(&ctx->gb, 17);
         ^
126.     huff.num = 0;
127. 

libavcodec/get_bits.h:289:1: start of procedure get_bits_long()
  287.  * Read 0-32 bits.
  288.  */
  289. static inline unsigned int get_bits_long(GetBitContext *s, int n){
       ^
  290.     if (n <= MIN_CACHE_BITS) return get_bits(s, n);
  291.     else {

libavcodec/get_bits.h:290:9: Taking true branch
  288.  */
  289. static inline unsigned int get_bits_long(GetBitContext *s, int n){
  290.     if (n <= MIN_CACHE_BITS) return get_bits(s, n);
               ^
  291.     else {
  292. #ifdef ALT_BITSTREAM_READER_LE

libavcodec/get_bits.h:290:30: 
  288.  */
  289. static inline unsigned int get_bits_long(GetBitContext *s, int n){
  290.     if (n <= MIN_CACHE_BITS) return get_bits(s, n);
                                    ^
  291.     else {
  292. #ifdef ALT_BITSTREAM_READER_LE

libavcodec/get_bits.h:230:1: start of procedure get_bits()
    228.  * Read 1-25 bits.
    229.  */
    230. static inline unsigned int get_bits(GetBitContext *s, int n){
         ^
    231.     register int tmp;
    232.     OPEN_READER(re, s);

libavcodec/get_bits.h:232:5: 
    230. static inline unsigned int get_bits(GetBitContext *s, int n){
    231.     register int tmp;
    232.     OPEN_READER(re, s);
             ^
    233.     UPDATE_CACHE(re, s);
    234.     tmp = SHOW_UBITS(re, s, n);

libavcodec/get_bits.h:233:5: 
    231.     register int tmp;
    232.     OPEN_READER(re, s);
    233.     UPDATE_CACHE(re, s);
             ^
    234.     tmp = SHOW_UBITS(re, s, n);
    235.     LAST_SKIP_BITS(re, s, n);

libavutil/bswap.h:66:1: start of procedure av_bswap32()
      64. 
      65. #ifndef av_bswap32
      66. static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
          ^
      67. {
      68.     return AV_BSWAP32C(x);

libavutil/bswap.h:68:5: 
      66. static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
      67. {
      68.     return AV_BSWAP32C(x);
              ^
      69. }
      70. #endif

libavutil/bswap.h:69:1: return from a call to av_bswap32
      67. {
      68.     return AV_BSWAP32C(x);
      69. }
          ^
      70. #endif
      71. 

libavcodec/get_bits.h:234:5: 
    232.     OPEN_READER(re, s);
    233.     UPDATE_CACHE(re, s);
    234.     tmp = SHOW_UBITS(re, s, n);
             ^
    235.     LAST_SKIP_BITS(re, s, n);
    236.     CLOSE_READER(re, s);

libavcodec/get_bits.h:235:5: Condition is false
    233.     UPDATE_CACHE(re, s);
    234.     tmp = SHOW_UBITS(re, s, n);
    235.     LAST_SKIP_BITS(re, s, n);
             ^
    236.     CLOSE_READER(re, s);
    237.     return tmp;

libavcodec/get_bits.h:236:5: 
    234.     tmp = SHOW_UBITS(re, s, n);
    235.     LAST_SKIP_BITS(re, s, n);
    236.     CLOSE_READER(re, s);
             ^
    237.     return tmp;
    238. }

libavcodec/get_bits.h:237:5: 
    235.     LAST_SKIP_BITS(re, s, n);
    236.     CLOSE_READER(re, s);
    237.     return tmp;
             ^
    238. }
    239. 

libavcodec/get_bits.h:238:1: return from a call to get_bits
    236.     CLOSE_READER(re, s);
    237.     return tmp;
    238. }
         ^
    239. 
    240. /**

libavcodec/get_bits.h:300:1: return from a call to get_bits_long
  298. #endif
  299.     }
  300. }
       ^
  301. 
  302. /**

libavcodec/truemotion2.c:126:5: 
124.     huff.min_bits = get_bits(&ctx->gb, 5);
125.     huff.nodes = get_bits_long(&ctx->gb, 17);
126.     huff.num = 0;
         ^
127. 
128.     /* check for correct codes parameters */

libavcodec/truemotion2.c:129:9: Taking false branch
127. 
128.     /* check for correct codes parameters */
129.     if((huff.val_bits < 1) || (huff.val_bits > 32) ||
             ^
130.        (huff.max_bits < 0) || (huff.max_bits > 32)) {
131.         av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect tree parameters - literal length: %i, max code length: %i\n",

libavcodec/truemotion2.c:129:32: Taking false branch
127. 
128.     /* check for correct codes parameters */
129.     if((huff.val_bits < 1) || (huff.val_bits > 32) ||
                                    ^
130.        (huff.max_bits < 0) || (huff.max_bits > 32)) {
131.         av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect tree parameters - literal length: %i, max code length: %i\n",

libavcodec/truemotion2.c:130:9: Taking false branch
128.     /* check for correct codes parameters */
129.     if((huff.val_bits < 1) || (huff.val_bits > 32) ||
130.        (huff.max_bits < 0) || (huff.max_bits > 32)) {
             ^
131.         av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect tree parameters - literal length: %i, max code length: %i\n",
132.                huff.val_bits, huff.max_bits);

libavcodec/truemotion2.c:130:32: Taking false branch
128.     /* check for correct codes parameters */
129.     if((huff.val_bits < 1) || (huff.val_bits > 32) ||
130.        (huff.max_bits < 0) || (huff.max_bits > 32)) {
                                    ^
131.         av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect tree parameters - literal length: %i, max code length: %i\n",
132.                huff.val_bits, huff.max_bits);

libavcodec/truemotion2.c:135:9: Taking false branch
133.         return -1;
134.     }
135.     if((huff.nodes < 0) || (huff.nodes > 0x10000)) {
             ^
136.         av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect number of Huffman tree nodes: %i\n", huff.nodes);
137.         return -1;

libavcodec/truemotion2.c:135:29: Taking false branch
133.         return -1;
134.     }
135.     if((huff.nodes < 0) || (huff.nodes > 0x10000)) {
                                 ^
136.         av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect number of Huffman tree nodes: %i\n", huff.nodes);
137.         return -1;

libavcodec/truemotion2.c:140:8: Taking false branch
138.     }
139.     /* one-node tree */
140.     if(huff.max_bits == 0)
            ^
141.         huff.max_bits = 1;
142. 

libavcodec/truemotion2.c:144:5: 
142. 
143.     /* allocate space for codes - it is exactly ceil(nodes / 2) entries */
144.     huff.max_num = (huff.nodes + 1) >> 1;
         ^
145.     huff.nums = av_mallocz(huff.max_num * sizeof(int));
146.     huff.bits = av_mallocz(huff.max_num * sizeof(uint32_t));

libavcodec/truemotion2.c:145:5: 
143.     /* allocate space for codes - it is exactly ceil(nodes / 2) entries */
144.     huff.max_num = (huff.nodes + 1) >> 1;
145.     huff.nums = av_mallocz(huff.max_num * sizeof(int));
         ^
146.     huff.bits = av_mallocz(huff.max_num * sizeof(uint32_t));
147.     huff.lens = av_mallocz(huff.max_num * sizeof(int));

libavutil/mem.c:154:1: start of procedure av_mallocz()
  152. }
  153. 
  154. void *av_mallocz(size_t size)
       ^
  155. {
  156.     void *ptr = av_malloc(size);

libavutil/mem.c:156:5: 
  154. void *av_mallocz(size_t size)
  155. {
  156.     void *ptr = av_malloc(size);
           ^
  157.     if (ptr)
  158.         memset(ptr, 0, size);

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

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

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

libavutil/mem.c:73:9: 
    71.     /* let's disallow possible ambiguous cases */
    72.     if(size > (INT_MAX-32) )
    73.         return NULL;
                ^
    74. 
    75. #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:157:9: Taking false branch
  155. {
  156.     void *ptr = av_malloc(size);
  157.     if (ptr)
               ^
  158.         memset(ptr, 0, size);
  159.     return ptr;

libavutil/mem.c:159:5: 
  157.     if (ptr)
  158.         memset(ptr, 0, size);
  159.     return ptr;
           ^
  160. }
  161. 

libavutil/mem.c:160:1: return from a call to av_mallocz
  158.         memset(ptr, 0, size);
  159.     return ptr;
  160. }
       ^
  161. 
  162. char *av_strdup(const char *s)

libavcodec/truemotion2.c:146:5: 
144.     huff.max_num = (huff.nodes + 1) >> 1;
145.     huff.nums = av_mallocz(huff.max_num * sizeof(int));
146.     huff.bits = av_mallocz(huff.max_num * sizeof(uint32_t));
         ^
147.     huff.lens = av_mallocz(huff.max_num * sizeof(int));
148. 

libavutil/mem.c:154:1: start of procedure av_mallocz()
  152. }
  153. 
  154. void *av_mallocz(size_t size)
       ^
  155. {
  156.     void *ptr = av_malloc(size);

libavutil/mem.c:156:5: 
  154. void *av_mallocz(size_t size)
  155. {
  156.     void *ptr = av_malloc(size);
           ^
  157.     if (ptr)
  158.         memset(ptr, 0, size);

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

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

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

libavutil/mem.c:73:9: 
    71.     /* let's disallow possible ambiguous cases */
    72.     if(size > (INT_MAX-32) )
    73.         return NULL;
                ^
    74. 
    75. #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:157:9: Taking false branch
  155. {
  156.     void *ptr = av_malloc(size);
  157.     if (ptr)
               ^
  158.         memset(ptr, 0, size);
  159.     return ptr;

libavutil/mem.c:159:5: 
  157.     if (ptr)
  158.         memset(ptr, 0, size);
  159.     return ptr;
           ^
  160. }
  161. 

libavutil/mem.c:160:1: return from a call to av_mallocz
  158.         memset(ptr, 0, size);
  159.     return ptr;
  160. }
       ^
  161. 
  162. char *av_strdup(const char *s)

libavcodec/truemotion2.c:147:5: 
145.     huff.nums = av_mallocz(huff.max_num * sizeof(int));
146.     huff.bits = av_mallocz(huff.max_num * sizeof(uint32_t));
147.     huff.lens = av_mallocz(huff.max_num * sizeof(int));
         ^
148. 
149.     if(tm2_read_tree(ctx, 0, 0, &huff) == -1)

libavutil/mem.c:154:1: start of procedure av_mallocz()
  152. }
  153. 
  154. void *av_mallocz(size_t size)
       ^
  155. {
  156.     void *ptr = av_malloc(size);

libavutil/mem.c:156:5: 
  154. void *av_mallocz(size_t size)
  155. {
  156.     void *ptr = av_malloc(size);
           ^
  157.     if (ptr)
  158.         memset(ptr, 0, size);

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

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

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

libavutil/mem.c:73:9: 
    71.     /* let's disallow possible ambiguous cases */
    72.     if(size > (INT_MAX-32) )
    73.         return NULL;
                ^
    74. 
    75. #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:157:9: Taking false branch
  155. {
  156.     void *ptr = av_malloc(size);
  157.     if (ptr)
               ^
  158.         memset(ptr, 0, size);
  159.     return ptr;

libavutil/mem.c:159:5: 
  157.     if (ptr)
  158.         memset(ptr, 0, size);
  159.     return ptr;
           ^
  160. }
  161. 

libavutil/mem.c:160:1: return from a call to av_mallocz
  158.         memset(ptr, 0, size);
  159.     return ptr;
  160. }
       ^
  161. 
  162. char *av_strdup(const char *s)

libavcodec/truemotion2.c:149:8: 
147.     huff.lens = av_mallocz(huff.max_num * sizeof(int));
148. 
149.     if(tm2_read_tree(ctx, 0, 0, &huff) == -1)
            ^
150.         res = -1;
151. 

libavcodec/truemotion2.c:88:1: start of procedure tm2_read_tree()
  86. } TM2Huff;
  87. 
  88. static int tm2_read_tree(TM2Context *ctx, uint32_t prefix, int length, TM2Huff *huff)
      ^
  89. {
  90.     if(length > huff->max_bits) {

libavcodec/truemotion2.c:90:8: Taking false branch
  88. static int tm2_read_tree(TM2Context *ctx, uint32_t prefix, int length, TM2Huff *huff)
  89. {
  90.     if(length > huff->max_bits) {
             ^
  91.         av_log(ctx->avctx, AV_LOG_ERROR, "Tree exceeded its given depth (%i)\n", huff->max_bits);
  92.         return -1;

libavcodec/truemotion2.c:95:9: 
  93.     }
  94. 
  95.     if(!get_bits1(&ctx->gb)) { /* literal */
              ^
  96.         if (length == 0) {
  97.             length = 1;

libavcodec/get_bits.h:259:1: start of procedure get_bits1()
    257. }
    258. 
    259. static inline unsigned int get_bits1(GetBitContext *s){
         ^
    260.     unsigned int index = s->index;
    261.     uint8_t result = s->buffer[index>>3];

libavcodec/get_bits.h:260:5: 
    258. 
    259. static inline unsigned int get_bits1(GetBitContext *s){
    260.     unsigned int index = s->index;
             ^
    261.     uint8_t result = s->buffer[index>>3];
    262. #ifdef ALT_BITSTREAM_READER_LE

libavcodec/get_bits.h:261:5: 
    259. static inline unsigned int get_bits1(GetBitContext *s){
    260.     unsigned int index = s->index;
    261.     uint8_t result = s->buffer[index>>3];
             ^
    262. #ifdef ALT_BITSTREAM_READER_LE
    263.     result >>= index & 7;

libavcodec/get_bits.h:263:5: 
    261.     uint8_t result = s->buffer[index>>3];
    262. #ifdef ALT_BITSTREAM_READER_LE
    263.     result >>= index & 7;
             ^
    264.     result &= 1;
    265. #else

libavcodec/get_bits.h:264:5: 
    262. #ifdef ALT_BITSTREAM_READER_LE
    263.     result >>= index & 7;
    264.     result &= 1;
             ^
    265. #else
    266.     result <<= index & 7;

libavcodec/get_bits.h:270:9: Taking true branch
    268. #endif
    269. #if !UNCHECKED_BITSTREAM_READER
    270.     if (s->index < s->size_in_bits_plus8)
                 ^
    271. #endif
    272.         index++;

libavcodec/get_bits.h:272:9: 
    270.     if (s->index < s->size_in_bits_plus8)
    271. #endif
    272.         index++;
                 ^
    273.     s->index = index;
    274. 

libavcodec/get_bits.h:273:5: 
    271. #endif
    272.         index++;
    273.     s->index = index;
             ^
    274. 
    275.     return result;

libavcodec/get_bits.h:275:5: 
    273.     s->index = index;
    274. 
    275.     return result;
             ^
    276. }
    277. 

libavcodec/get_bits.h:276:1: return from a call to get_bits1
    274. 
    275.     return result;
    276. }
         ^
    277. 
    278. static inline unsigned int show_bits1(GetBitContext *s){

libavcodec/truemotion2.c:95:9: Taking true branch
  93.     }
  94. 
  95.     if(!get_bits1(&ctx->gb)) { /* literal */
              ^
  96.         if (length == 0) {
  97.             length = 1;

libavcodec/truemotion2.c:96:13: Taking true branch
  94. 
  95.     if(!get_bits1(&ctx->gb)) { /* literal */
  96.         if (length == 0) {
                  ^
  97.             length = 1;
  98.         }

libavcodec/truemotion2.c:97:13: 
  95.     if(!get_bits1(&ctx->gb)) { /* literal */
  96.         if (length == 0) {
  97.             length = 1;
                  ^
  98.         }
  99.         if(huff->num >= huff->max_num) {

libavcodec/truemotion2.c:99:12: Taking false branch
   97.             length = 1;
   98.         }
   99.         if(huff->num >= huff->max_num) {
                  ^
  100.             av_log(ctx->avctx, AV_LOG_DEBUG, "Too many literals\n");
  101.             return -1;

libavcodec/truemotion2.c:103:9: 
  101.             return -1;
  102.         }
  103.         huff->nums[huff->num] = get_bits_long(&ctx->gb, huff->val_bits);
               ^
  104.         huff->bits[huff->num] = prefix;
  105.         huff->lens[huff->num] = length;

libavcodec/get_bits.h:289:1: start of procedure get_bits_long()
    287.  * Read 0-32 bits.
    288.  */
    289. static inline unsigned int get_bits_long(GetBitContext *s, int n){
         ^
    290.     if (n <= MIN_CACHE_BITS) return get_bits(s, n);
    291.     else {

libavcodec/get_bits.h:290:9: Taking true branch
    288.  */
    289. static inline unsigned int get_bits_long(GetBitContext *s, int n){
    290.     if (n <= MIN_CACHE_BITS) return get_bits(s, n);
                 ^
    291.     else {
    292. #ifdef ALT_BITSTREAM_READER_LE

libavcodec/get_bits.h:290:30: 
    288.  */
    289. static inline unsigned int get_bits_long(GetBitContext *s, int n){
    290.     if (n <= MIN_CACHE_BITS) return get_bits(s, n);
                                      ^
    291.     else {
    292. #ifdef ALT_BITSTREAM_READER_LE

libavcodec/get_bits.h:230:1: start of procedure get_bits()
      228.  * Read 1-25 bits.
      229.  */
      230. static inline unsigned int get_bits(GetBitContext *s, int n){
           ^
      231.     register int tmp;
      232.     OPEN_READER(re, s);

libavcodec/get_bits.h:232:5: 
      230. static inline unsigned int get_bits(GetBitContext *s, int n){
      231.     register int tmp;
      232.     OPEN_READER(re, s);
               ^
      233.     UPDATE_CACHE(re, s);
      234.     tmp = SHOW_UBITS(re, s, n);

libavcodec/get_bits.h:233:5: 
      231.     register int tmp;
      232.     OPEN_READER(re, s);
      233.     UPDATE_CACHE(re, s);
               ^
      234.     tmp = SHOW_UBITS(re, s, n);
      235.     LAST_SKIP_BITS(re, s, n);

libavutil/bswap.h:66:1: start of procedure av_bswap32()
        64. 
        65. #ifndef av_bswap32
        66. static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
            ^
        67. {
        68.     return AV_BSWAP32C(x);

libavutil/bswap.h:68:5: 
        66. static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
        67. {
        68.     return AV_BSWAP32C(x);
                ^
        69. }
        70. #endif

libavutil/bswap.h:69:1: return from a call to av_bswap32
        67. {
        68.     return AV_BSWAP32C(x);
        69. }
            ^
        70. #endif
        71. 

libavcodec/get_bits.h:234:5: 
      232.     OPEN_READER(re, s);
      233.     UPDATE_CACHE(re, s);
      234.     tmp = SHOW_UBITS(re, s, n);
               ^
      235.     LAST_SKIP_BITS(re, s, n);
      236.     CLOSE_READER(re, s);

libavcodec/get_bits.h:235:5: Condition is true
      233.     UPDATE_CACHE(re, s);
      234.     tmp = SHOW_UBITS(re, s, n);
      235.     LAST_SKIP_BITS(re, s, n);
               ^
      236.     CLOSE_READER(re, s);
      237.     return tmp;

libavcodec/get_bits.h:236:5: 
      234.     tmp = SHOW_UBITS(re, s, n);
      235.     LAST_SKIP_BITS(re, s, n);
      236.     CLOSE_READER(re, s);
               ^
      237.     return tmp;
      238. }

libavcodec/get_bits.h:237:5: 
      235.     LAST_SKIP_BITS(re, s, n);
      236.     CLOSE_READER(re, s);
      237.     return tmp;
               ^
      238. }
      239. 

libavcodec/get_bits.h:238:1: return from a call to get_bits
      236.     CLOSE_READER(re, s);
      237.     return tmp;
      238. }
           ^
      239. 
      240. /**

libavcodec/get_bits.h:300:1: return from a call to get_bits_long
    298. #endif
    299.     }
    300. }
         ^
    301. 
    302. /**

libavcodec/truemotion2.c:104:9: 
  102.         }
  103.         huff->nums[huff->num] = get_bits_long(&ctx->gb, huff->val_bits);
  104.         huff->bits[huff->num] = prefix;
               ^
  105.         huff->lens[huff->num] = length;
  106.         huff->num++;

static int tm2_build_huff_table(TM2Context *ctx, TM2Codes *code)
{
    TM2Huff huff;
    int res = 0;
    huff.val_bits = get_bits(&ctx->gb, 5);
    huff.max_bits = get_bits(&ctx->gb, 5);
    huff.min_bits = get_bits(&ctx->gb, 5);
    huff.nodes = get_bits_long(&ctx->gb, 17);
    huff.num = 0;
    if((huff.val_bits < 1) || (huff.val_bits > 32) ||
       (huff.max_bits < 0) || (huff.max_bits > 32)) {
        av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect tree parameters - literal length: %i, max code length: %i\n",
               huff.val_bits, huff.max_bits);
        return -1;
    }
    if((huff.nodes < 0) || (huff.nodes > 0x10000)) {
        av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect number of Huffman tree nodes: %i\n", huff.nodes);
        return -1;
    }
    if(huff.max_bits == 0)
        huff.max_bits = 1;
    huff.max_num = (huff.nodes + 1) >> 1;
    huff.nums = av_mallocz(huff.max_num * sizeof(int));
    huff.bits = av_mallocz(huff.max_num * sizeof(uint32_t));
    huff.lens = av_mallocz(huff.max_num * sizeof(int));
    if(tm2_read_tree(ctx, 0, 0, &huff) == -1)
        res = -1;
    if(huff.num != huff.max_num) {
        av_log(ctx->avctx, AV_LOG_ERROR, "Got less codes than expected: %i of %i\n",
               huff.num, huff.max_num);
        res = -1;
    }
    if(res != -1) {
        int i;
        res = init_vlc(&code->vlc, huff.max_bits, huff.max_num,
                    huff.lens, sizeof(int), sizeof(int),
                    huff.bits, sizeof(uint32_t), sizeof(uint32_t), 0);
        if(res < 0) {
            av_log(ctx->avctx, AV_LOG_ERROR, "Cannot build VLC table\n");
            res = -1;
        } else
            res = 0;
        if(res != -1) {
            code->bits = huff.max_bits;
            code->length = huff.max_num;
            code->recode = av_malloc(code->length * sizeof(int));
            for(i = 0; i < code->length; i++)
                code->recode[i] = huff.nums[i];
        }
    }
    av_free(huff.nums);
    av_free(huff.bits);
    av_free(huff.lens);
    return res;
}
['static int tm2_build_huff_table(TM2Context *ctx, TM2Codes *code)\n{\n    TM2Huff huff;\n    int res = 0;\n    huff.val_bits = get_bits(&ctx->gb, 5);\n    huff.max_bits = get_bits(&ctx->gb, 5);\n    huff.min_bits = get_bits(&ctx->gb, 5);\n    huff.nodes = get_bits_long(&ctx->gb, 17);\n    huff.num = 0;\n    if((huff.val_bits < 1) || (huff.val_bits > 32) ||\n       (huff.max_bits < 0) || (huff.max_bits > 32)) {\n        av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect tree parameters - literal length: %i, max code length: %i\\n",\n               huff.val_bits, huff.max_bits);\n        return -1;\n    }\n    if((huff.nodes < 0) || (huff.nodes > 0x10000)) {\n        av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect number of Huffman tree nodes: %i\\n", huff.nodes);\n        return -1;\n    }\n    if(huff.max_bits == 0)\n        huff.max_bits = 1;\n    huff.max_num = (huff.nodes + 1) >> 1;\n    huff.nums = av_mallocz(huff.max_num * sizeof(int));\n    huff.bits = av_mallocz(huff.max_num * sizeof(uint32_t));\n    huff.lens = av_mallocz(huff.max_num * sizeof(int));\n    if(tm2_read_tree(ctx, 0, 0, &huff) == -1)\n        res = -1;\n    if(huff.num != huff.max_num) {\n        av_log(ctx->avctx, AV_LOG_ERROR, "Got less codes than expected: %i of %i\\n",\n               huff.num, huff.max_num);\n        res = -1;\n    }\n    if(res != -1) {\n        int i;\n        res = init_vlc(&code->vlc, huff.max_bits, huff.max_num,\n                    huff.lens, sizeof(int), sizeof(int),\n                    huff.bits, sizeof(uint32_t), sizeof(uint32_t), 0);\n        if(res < 0) {\n            av_log(ctx->avctx, AV_LOG_ERROR, "Cannot build VLC table\\n");\n            res = -1;\n        } else\n            res = 0;\n        if(res != -1) {\n            code->bits = huff.max_bits;\n            code->length = huff.max_num;\n            code->recode = av_malloc(code->length * sizeof(int));\n            for(i = 0; i < code->length; i++)\n                code->recode[i] = huff.nums[i];\n        }\n    }\n    av_free(huff.nums);\n    av_free(huff.bits);\n    av_free(huff.lens);\n    return res;\n}', 'static inline unsigned int get_bits(GetBitContext *s, int n){\n    register int tmp;\n    OPEN_READER(re, s);\n    UPDATE_CACHE(re, s);\n    tmp = SHOW_UBITS(re, s, n);\n    LAST_SKIP_BITS(re, s, n);\n    CLOSE_READER(re, s);\n    return tmp;\n}', 'static av_always_inline av_const uint32_t av_bswap32(uint32_t x)\n{\n    return AV_BSWAP32C(x);\n}', 'static inline unsigned int get_bits_long(GetBitContext *s, int n){\n    if (n <= MIN_CACHE_BITS) return get_bits(s, n);\n    else {\n#ifdef ALT_BITSTREAM_READER_LE\n        int ret = get_bits(s, 16);\n        return ret | (get_bits(s, n-16) << 16);\n#else\n        int ret = get_bits(s, 16) << (n-16);\n        return ret | get_bits(s, n-16);\n#endif\n    }\n}', 'void *av_mallocz(size_t size)\n{\n    void *ptr = av_malloc(size);\n    if (ptr)\n        memset(ptr, 0, size);\n    return ptr;\n}', 'void *av_malloc(size_t size)\n{\n    void *ptr = NULL;\n#if CONFIG_MEMALIGN_HACK\n    long diff;\n#endif\n    if(size > (INT_MAX-32) )\n        return NULL;\n#if CONFIG_MEMALIGN_HACK\n    ptr = malloc(size+32);\n    if(!ptr)\n        return ptr;\n    diff= ((-(long)ptr - 1)&31) + 1;\n    ptr = (char*)ptr + diff;\n    ((char*)ptr)[-1]= diff;\n#elif HAVE_POSIX_MEMALIGN\n    if (posix_memalign(&ptr,32,size))\n        ptr = NULL;\n#elif HAVE_MEMALIGN\n    ptr = memalign(32,size);\n#else\n    ptr = malloc(size);\n#endif\n    return ptr;\n}', 'static int tm2_read_tree(TM2Context *ctx, uint32_t prefix, int length, TM2Huff *huff)\n{\n    if(length > huff->max_bits) {\n        av_log(ctx->avctx, AV_LOG_ERROR, "Tree exceeded its given depth (%i)\\n", huff->max_bits);\n        return -1;\n    }\n    if(!get_bits1(&ctx->gb)) {\n        if (length == 0) {\n            length = 1;\n        }\n        if(huff->num >= huff->max_num) {\n            av_log(ctx->avctx, AV_LOG_DEBUG, "Too many literals\\n");\n            return -1;\n        }\n        huff->nums[huff->num] = get_bits_long(&ctx->gb, huff->val_bits);\n        huff->bits[huff->num] = prefix;\n        huff->lens[huff->num] = length;\n        huff->num++;\n        return 0;\n    } else {\n        if(tm2_read_tree(ctx, prefix << 1, length + 1, huff) == -1)\n            return -1;\n        if(tm2_read_tree(ctx, (prefix << 1) | 1, length + 1, huff) == -1)\n            return -1;\n    }\n    return 0;\n}', 'static inline unsigned int get_bits1(GetBitContext *s){\n    unsigned int index = s->index;\n    uint8_t result = s->buffer[index>>3];\n#ifdef ALT_BITSTREAM_READER_LE\n    result >>= index & 7;\n    result &= 1;\n#else\n    result <<= index & 7;\n    result >>= 8 - 1;\n#endif\n#if !UNCHECKED_BITSTREAM_READER\n    if (s->index < s->size_in_bits_plus8)\n#endif\n        index++;\n    s->index = index;\n    return result;\n}']