libavcodec/smacker.c:626: error: Null Dereference
  pointer `&gb->buffer` last assigned on line 624 could be null and is dereferenced by call to `get_bits1()` at line 626, column 9.

libavcodec/smacker.c:600:1: start of procedure smka_decode_frame()
598.  * Decode Smacker audio data
599.  */
600. static int smka_decode_frame(AVCodecContext *avctx, void *data,
     ^
601.                              int *got_frame_ptr, AVPacket *avpkt)
602. {

libavcodec/smacker.c:603:5: 
601.                              int *got_frame_ptr, AVPacket *avpkt)
602. {
603.     AVFrame *frame     = data;
         ^
604.     const uint8_t *buf = avpkt->data;
605.     int buf_size = avpkt->size;

libavcodec/smacker.c:604:5: 
602. {
603.     AVFrame *frame     = data;
604.     const uint8_t *buf = avpkt->data;
         ^
605.     int buf_size = avpkt->size;
606.     GetBitContext gb;

libavcodec/smacker.c:605:5: 
603.     AVFrame *frame     = data;
604.     const uint8_t *buf = avpkt->data;
605.     int buf_size = avpkt->size;
         ^
606.     GetBitContext gb;
607.     HuffContext h[4] = { { 0 } };

libavcodec/smacker.c:607:5: 
605.     int buf_size = avpkt->size;
606.     GetBitContext gb;
607.     HuffContext h[4] = { { 0 } };
         ^
608.     VLC vlc[4]       = { { 0 } };
609.     int16_t *samples;

libavcodec/smacker.c:608:5: 
606.     GetBitContext gb;
607.     HuffContext h[4] = { { 0 } };
608.     VLC vlc[4]       = { { 0 } };
         ^
609.     int16_t *samples;
610.     uint8_t *samples8;

libavcodec/smacker.c:615:5: 
613.     int unp_size;
614.     int bits, stereo;
615.     int pred[2] = {0, 0};
         ^
616. 
617.     if (buf_size <= 4) {

libavcodec/smacker.c:617:9: Taking false branch
615.     int pred[2] = {0, 0};
616. 
617.     if (buf_size <= 4) {
             ^
618.         av_log(avctx, AV_LOG_ERROR, "packet is too small\n");
619.         return AVERROR(EINVAL);

libavcodec/smacker.c:622:5: 
620.     }
621. 
622.     unp_size = AV_RL32(buf);
         ^
623. 
624.     init_get_bits(&gb, buf + 4, (buf_size - 4) * 8);

libavutil/ppc/intreadwrite.h:44:1: start of procedure AV_RL32()
  42. 
  43. #define AV_RL32 AV_RL32
  44. static av_always_inline uint32_t AV_RL32(const void *p)
      ^
  45. {
  46.     uint32_t v;

libavutil/ppc/intreadwrite.h:47:5: Skipping __infer_skip_gcc_asm_stmt(): function or method not found
  45. {
  46.     uint32_t v;
  47.     __asm__ ("lwbrx   %0, %y1" : "=r"(v) : "Z"(*(const uint32_t*)p));
          ^
  48.     return v;
  49. }

libavutil/ppc/intreadwrite.h:48:5: 
  46.     uint32_t v;
  47.     __asm__ ("lwbrx   %0, %y1" : "=r"(v) : "Z"(*(const uint32_t*)p));
  48.     return v;
          ^
  49. }
  50. 

libavutil/ppc/intreadwrite.h:49:1: return from a call to AV_RL32
  47.     __asm__ ("lwbrx   %0, %y1" : "=r"(v) : "Z"(*(const uint32_t*)p));
  48.     return v;
  49. }
      ^
  50. 
  51. #define AV_WL32 AV_WL32

libavcodec/smacker.c:624:5: 
622.     unp_size = AV_RL32(buf);
623. 
624.     init_get_bits(&gb, buf + 4, (buf_size - 4) * 8);
         ^
625. 
626.     if(!get_bits1(&gb)){

libavcodec/get_bits.h:375:1: start of procedure init_get_bits()
  373.  * @return 0 on success, AVERROR_INVALIDDATA if the buffer_size would overflow.
  374.  */
  375. static inline int init_get_bits(GetBitContext *s, const uint8_t *buffer,
       ^
  376.                                 int bit_size)
  377. {

libavcodec/get_bits.h:379:5: 
  377. {
  378.     int buffer_size;
  379.     int ret = 0;
           ^
  380. 
  381.     if (bit_size > INT_MAX - 7 || bit_size < 0 || !buffer) {

libavcodec/get_bits.h:381:9: Taking true branch
  379.     int ret = 0;
  380. 
  381.     if (bit_size > INT_MAX - 7 || bit_size < 0 || !buffer) {
               ^
  382.         buffer_size = bit_size = 0;
  383.         buffer      = NULL;

libavcodec/get_bits.h:382:9: 
  380. 
  381.     if (bit_size > INT_MAX - 7 || bit_size < 0 || !buffer) {
  382.         buffer_size = bit_size = 0;
               ^
  383.         buffer      = NULL;
  384.         ret         = AVERROR_INVALIDDATA;

libavcodec/get_bits.h:383:9: 
  381.     if (bit_size > INT_MAX - 7 || bit_size < 0 || !buffer) {
  382.         buffer_size = bit_size = 0;
  383.         buffer      = NULL;
               ^
  384.         ret         = AVERROR_INVALIDDATA;
  385.     }

libavcodec/get_bits.h:384:9: 
  382.         buffer_size = bit_size = 0;
  383.         buffer      = NULL;
  384.         ret         = AVERROR_INVALIDDATA;
               ^
  385.     }
  386. 

libavcodec/get_bits.h:387:5: 
  385.     }
  386. 
  387.     buffer_size = (bit_size + 7) >> 3;
           ^
  388. 
  389.     s->buffer             = buffer;

libavcodec/get_bits.h:389:5: 
  387.     buffer_size = (bit_size + 7) >> 3;
  388. 
  389.     s->buffer             = buffer;
           ^
  390.     s->size_in_bits       = bit_size;
  391. #if !UNCHECKED_BITSTREAM_READER

libavcodec/get_bits.h:390:5: 
  388. 
  389.     s->buffer             = buffer;
  390.     s->size_in_bits       = bit_size;
           ^
  391. #if !UNCHECKED_BITSTREAM_READER
  392.     s->size_in_bits_plus8 = bit_size + 8;

libavcodec/get_bits.h:392:5: 
  390.     s->size_in_bits       = bit_size;
  391. #if !UNCHECKED_BITSTREAM_READER
  392.     s->size_in_bits_plus8 = bit_size + 8;
           ^
  393. #endif
  394.     s->buffer_end         = buffer + buffer_size;

libavcodec/get_bits.h:394:5: 
  392.     s->size_in_bits_plus8 = bit_size + 8;
  393. #endif
  394.     s->buffer_end         = buffer + buffer_size;
           ^
  395.     s->index              = 0;
  396. 

libavcodec/get_bits.h:395:5: 
  393. #endif
  394.     s->buffer_end         = buffer + buffer_size;
  395.     s->index              = 0;
           ^
  396. 
  397.     return ret;

libavcodec/get_bits.h:397:5: 
  395.     s->index              = 0;
  396. 
  397.     return ret;
           ^
  398. }
  399. 

libavcodec/get_bits.h:398:1: return from a call to init_get_bits
  396. 
  397.     return ret;
  398. }
       ^
  399. 
  400. /**

libavcodec/smacker.c:626:9: 
624.     init_get_bits(&gb, buf + 4, (buf_size - 4) * 8);
625. 
626.     if(!get_bits1(&gb)){
             ^
627.         av_log(avctx, AV_LOG_INFO, "Sound: no data\n");
628.         *got_frame_ptr = 0;

libavcodec/get_bits.h:271:1: start of procedure get_bits1()
  269. }
  270. 
  271. static inline unsigned int get_bits1(GetBitContext *s)
       ^
  272. {
  273.     unsigned int index = s->index;

libavcodec/get_bits.h:273:5: 
  271. static inline unsigned int get_bits1(GetBitContext *s)
  272. {
  273.     unsigned int index = s->index;
           ^
  274.     uint8_t result     = s->buffer[index >> 3];
  275. #ifdef BITSTREAM_READER_LE

libavcodec/get_bits.h:274:5: 
  272. {
  273.     unsigned int index = s->index;
  274.     uint8_t result     = s->buffer[index >> 3];
           ^
  275. #ifdef BITSTREAM_READER_LE
  276.     result >>= index & 7;

static int smka_decode_frame(AVCodecContext *avctx, void *data,
                             int *got_frame_ptr, AVPacket *avpkt)
{
    AVFrame *frame     = data;
    const uint8_t *buf = avpkt->data;
    int buf_size = avpkt->size;
    GetBitContext gb;
    HuffContext h[4] = { { 0 } };
    VLC vlc[4]       = { { 0 } };
    int16_t *samples;
    uint8_t *samples8;
    int val;
    int i, res, ret;
    int unp_size;
    int bits, stereo;
    int pred[2] = {0, 0};
    if (buf_size <= 4) {
        av_log(avctx, AV_LOG_ERROR, "packet is too small\n");
        return AVERROR(EINVAL);
    }
    unp_size = AV_RL32(buf);
    init_get_bits(&gb, buf + 4, (buf_size - 4) * 8);
    if(!get_bits1(&gb)){
        av_log(avctx, AV_LOG_INFO, "Sound: no data\n");
        *got_frame_ptr = 0;
        return 1;
    }
    stereo = get_bits1(&gb);
    bits = get_bits1(&gb);
    if (stereo ^ (avctx->channels != 1)) {
        av_log(avctx, AV_LOG_ERROR, "channels mismatch\n");
        return AVERROR(EINVAL);
    }
    if (bits && avctx->sample_fmt == AV_SAMPLE_FMT_U8) {
        av_log(avctx, AV_LOG_ERROR, "sample format mismatch\n");
        return AVERROR(EINVAL);
    }
    frame->nb_samples = unp_size / (avctx->channels * (bits + 1));
    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
        return ret;
    }
    samples  = (int16_t *)frame->data[0];
    samples8 =            frame->data[0];
    for(i = 0; i < (1 << (bits + stereo)); i++) {
        h[i].length = 256;
        h[i].maxlength = 0;
        h[i].current = 0;
        h[i].bits = av_mallocz(256 * 4);
        h[i].lengths = av_mallocz(256 * sizeof(int));
        h[i].values = av_mallocz(256 * sizeof(int));
        if (!h[i].bits || !h[i].lengths || !h[i].values) {
            ret = AVERROR(ENOMEM);
            goto error;
        }
        skip_bits1(&gb);
        if (smacker_decode_tree(&gb, &h[i], 0, 0) < 0) {
            ret = AVERROR_INVALIDDATA;
            goto error;
        }
        skip_bits1(&gb);
        if(h[i].current > 1) {
            res = init_vlc(&vlc[i], SMKTREE_BITS, h[i].length,
                    h[i].lengths, sizeof(int), sizeof(int),
                    h[i].bits, sizeof(uint32_t), sizeof(uint32_t), INIT_VLC_LE);
            if(res < 0) {
                av_log(avctx, AV_LOG_ERROR, "Cannot build VLC table\n");
                ret = AVERROR_INVALIDDATA;
                goto error;
            }
        }
    }
    if(bits) {
        for(i = stereo; i >= 0; i--)
            pred[i] = sign_extend(av_bswap16(get_bits(&gb, 16)), 16);
        for(i = 0; i <= stereo; i++)
            *samples++ = pred[i];
        for(; i < unp_size / 2; i++) {
            if(i & stereo) {
                if(vlc[2].table)
                    res = get_vlc2(&gb, vlc[2].table, SMKTREE_BITS, 3);
                else
                    res = 0;
                val  = h[2].values[res];
                if(vlc[3].table)
                    res = get_vlc2(&gb, vlc[3].table, SMKTREE_BITS, 3);
                else
                    res = 0;
                val |= h[3].values[res] << 8;
                pred[1] += sign_extend(val, 16);
                *samples++ = pred[1];
            } else {
                if(vlc[0].table)
                    res = get_vlc2(&gb, vlc[0].table, SMKTREE_BITS, 3);
                else
                    res = 0;
                val  = h[0].values[res];
                if(vlc[1].table)
                    res = get_vlc2(&gb, vlc[1].table, SMKTREE_BITS, 3);
                else
                    res = 0;
                val |= h[1].values[res] << 8;
                pred[0] += sign_extend(val, 16);
                *samples++ = pred[0];
            }
        }
    } else {
        for(i = stereo; i >= 0; i--)
            pred[i] = get_bits(&gb, 8);
        for(i = 0; i <= stereo; i++)
            *samples8++ = pred[i];
        for(; i < unp_size; i++) {
            if(i & stereo){
                if(vlc[1].table)
                    res = get_vlc2(&gb, vlc[1].table, SMKTREE_BITS, 3);
                else
                    res = 0;
                pred[1] += sign_extend(h[1].values[res], 8);
                *samples8++ = pred[1];
            } else {
                if(vlc[0].table)
                    res = get_vlc2(&gb, vlc[0].table, SMKTREE_BITS, 3);
                else
                    res = 0;
                pred[0] += sign_extend(h[0].values[res], 8);
                *samples8++ = pred[0];
            }
        }
    }
    *got_frame_ptr = 1;
    ret = buf_size;
error:
    for(i = 0; i < 4; i++) {
        if(vlc[i].table)
            ff_free_vlc(&vlc[i]);
        av_free(h[i].bits);
        av_free(h[i].lengths);
        av_free(h[i].values);
    }
    return ret;
}
['static int smka_decode_frame(AVCodecContext *avctx, void *data,\n                             int *got_frame_ptr, AVPacket *avpkt)\n{\n    AVFrame *frame     = data;\n    const uint8_t *buf = avpkt->data;\n    int buf_size = avpkt->size;\n    GetBitContext gb;\n    HuffContext h[4] = { { 0 } };\n    VLC vlc[4]       = { { 0 } };\n    int16_t *samples;\n    uint8_t *samples8;\n    int val;\n    int i, res, ret;\n    int unp_size;\n    int bits, stereo;\n    int pred[2] = {0, 0};\n    if (buf_size <= 4) {\n        av_log(avctx, AV_LOG_ERROR, "packet is too small\\n");\n        return AVERROR(EINVAL);\n    }\n    unp_size = AV_RL32(buf);\n    init_get_bits(&gb, buf + 4, (buf_size - 4) * 8);\n    if(!get_bits1(&gb)){\n        av_log(avctx, AV_LOG_INFO, "Sound: no data\\n");\n        *got_frame_ptr = 0;\n        return 1;\n    }\n    stereo = get_bits1(&gb);\n    bits = get_bits1(&gb);\n    if (stereo ^ (avctx->channels != 1)) {\n        av_log(avctx, AV_LOG_ERROR, "channels mismatch\\n");\n        return AVERROR(EINVAL);\n    }\n    if (bits && avctx->sample_fmt == AV_SAMPLE_FMT_U8) {\n        av_log(avctx, AV_LOG_ERROR, "sample format mismatch\\n");\n        return AVERROR(EINVAL);\n    }\n    frame->nb_samples = unp_size / (avctx->channels * (bits + 1));\n    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {\n        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\\n");\n        return ret;\n    }\n    samples  = (int16_t *)frame->data[0];\n    samples8 =            frame->data[0];\n    for(i = 0; i < (1 << (bits + stereo)); i++) {\n        h[i].length = 256;\n        h[i].maxlength = 0;\n        h[i].current = 0;\n        h[i].bits = av_mallocz(256 * 4);\n        h[i].lengths = av_mallocz(256 * sizeof(int));\n        h[i].values = av_mallocz(256 * sizeof(int));\n        if (!h[i].bits || !h[i].lengths || !h[i].values) {\n            ret = AVERROR(ENOMEM);\n            goto error;\n        }\n        skip_bits1(&gb);\n        if (smacker_decode_tree(&gb, &h[i], 0, 0) < 0) {\n            ret = AVERROR_INVALIDDATA;\n            goto error;\n        }\n        skip_bits1(&gb);\n        if(h[i].current > 1) {\n            res = init_vlc(&vlc[i], SMKTREE_BITS, h[i].length,\n                    h[i].lengths, sizeof(int), sizeof(int),\n                    h[i].bits, sizeof(uint32_t), sizeof(uint32_t), INIT_VLC_LE);\n            if(res < 0) {\n                av_log(avctx, AV_LOG_ERROR, "Cannot build VLC table\\n");\n                ret = AVERROR_INVALIDDATA;\n                goto error;\n            }\n        }\n    }\n    if(bits) {\n        for(i = stereo; i >= 0; i--)\n            pred[i] = sign_extend(av_bswap16(get_bits(&gb, 16)), 16);\n        for(i = 0; i <= stereo; i++)\n            *samples++ = pred[i];\n        for(; i < unp_size / 2; i++) {\n            if(i & stereo) {\n                if(vlc[2].table)\n                    res = get_vlc2(&gb, vlc[2].table, SMKTREE_BITS, 3);\n                else\n                    res = 0;\n                val  = h[2].values[res];\n                if(vlc[3].table)\n                    res = get_vlc2(&gb, vlc[3].table, SMKTREE_BITS, 3);\n                else\n                    res = 0;\n                val |= h[3].values[res] << 8;\n                pred[1] += sign_extend(val, 16);\n                *samples++ = pred[1];\n            } else {\n                if(vlc[0].table)\n                    res = get_vlc2(&gb, vlc[0].table, SMKTREE_BITS, 3);\n                else\n                    res = 0;\n                val  = h[0].values[res];\n                if(vlc[1].table)\n                    res = get_vlc2(&gb, vlc[1].table, SMKTREE_BITS, 3);\n                else\n                    res = 0;\n                val |= h[1].values[res] << 8;\n                pred[0] += sign_extend(val, 16);\n                *samples++ = pred[0];\n            }\n        }\n    } else {\n        for(i = stereo; i >= 0; i--)\n            pred[i] = get_bits(&gb, 8);\n        for(i = 0; i <= stereo; i++)\n            *samples8++ = pred[i];\n        for(; i < unp_size; i++) {\n            if(i & stereo){\n                if(vlc[1].table)\n                    res = get_vlc2(&gb, vlc[1].table, SMKTREE_BITS, 3);\n                else\n                    res = 0;\n                pred[1] += sign_extend(h[1].values[res], 8);\n                *samples8++ = pred[1];\n            } else {\n                if(vlc[0].table)\n                    res = get_vlc2(&gb, vlc[0].table, SMKTREE_BITS, 3);\n                else\n                    res = 0;\n                pred[0] += sign_extend(h[0].values[res], 8);\n                *samples8++ = pred[0];\n            }\n        }\n    }\n    *got_frame_ptr = 1;\n    ret = buf_size;\nerror:\n    for(i = 0; i < 4; i++) {\n        if(vlc[i].table)\n            ff_free_vlc(&vlc[i]);\n        av_free(h[i].bits);\n        av_free(h[i].lengths);\n        av_free(h[i].values);\n    }\n    return ret;\n}', 'static inline int init_get_bits(GetBitContext *s, const uint8_t *buffer,\n                                int bit_size)\n{\n    int buffer_size;\n    int ret = 0;\n    if (bit_size > INT_MAX - 7 || bit_size < 0 || !buffer) {\n        buffer_size = bit_size = 0;\n        buffer      = NULL;\n        ret         = AVERROR_INVALIDDATA;\n    }\n    buffer_size = (bit_size + 7) >> 3;\n    s->buffer             = buffer;\n    s->size_in_bits       = bit_size;\n#if !UNCHECKED_BITSTREAM_READER\n    s->size_in_bits_plus8 = bit_size + 8;\n#endif\n    s->buffer_end         = buffer + buffer_size;\n    s->index              = 0;\n    return ret;\n}', 'static inline unsigned int get_bits1(GetBitContext *s)\n{\n    unsigned int index = s->index;\n    uint8_t result     = s->buffer[index >> 3];\n#ifdef 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}']