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

libavcodec/smacker.c:575:1: start of procedure smka_decode_frame()
573.  * Decode Smacker audio data
574.  */
575. static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
     ^
576. {
577.     const uint8_t *buf = avpkt->data;

libavcodec/smacker.c:577:5: 
575. static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
576. {
577.     const uint8_t *buf = avpkt->data;
         ^
578.     int buf_size = avpkt->size;
579.     GetBitContext gb;

libavcodec/smacker.c:578:5: 
576. {
577.     const uint8_t *buf = avpkt->data;
578.     int buf_size = avpkt->size;
         ^
579.     GetBitContext gb;
580.     HuffContext h[4];

libavcodec/smacker.c:582:5: 
580.     HuffContext h[4];
581.     VLC vlc[4];
582.     int16_t *samples = data;
         ^
583.     uint8_t *samples8 = data;
584.     int val;

libavcodec/smacker.c:583:5: 
581.     VLC vlc[4];
582.     int16_t *samples = data;
583.     uint8_t *samples8 = data;
         ^
584.     int val;
585.     int i, res;

libavcodec/smacker.c:588:5: 
586.     int unp_size;
587.     int bits, stereo;
588.     int pred[2] = {0, 0};
         ^
589. 
590.     if (buf_size <= 4) {

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

libavcodec/smacker.c:595:5: 
593.     }
594. 
595.     unp_size = AV_RL32(buf);
         ^
596. 
597.     init_get_bits(&gb, buf + 4, (buf_size - 4) * 8);

libavcodec/smacker.c:597:5: 
595.     unp_size = AV_RL32(buf);
596. 
597.     init_get_bits(&gb, buf + 4, (buf_size - 4) * 8);
         ^
598. 
599.     if(!get_bits1(&gb)){

libavcodec/get_bits.h:383:1: start of procedure init_get_bits()
  381.  * responsible for checking for the buffer end yourself (take advantage of the padding)!
  382.  */
  383. static inline void init_get_bits(GetBitContext *s,
       ^
  384.                    const uint8_t *buffer, int bit_size)
  385. {

libavcodec/get_bits.h:386:5: 
  384.                    const uint8_t *buffer, int bit_size)
  385. {
  386.     int buffer_size = (bit_size+7)>>3;
           ^
  387.     if (buffer_size < 0 || bit_size < 0) {
  388.         buffer_size = bit_size = 0;

libavcodec/get_bits.h:387:9: Taking true branch
  385. {
  386.     int buffer_size = (bit_size+7)>>3;
  387.     if (buffer_size < 0 || bit_size < 0) {
               ^
  388.         buffer_size = bit_size = 0;
  389.         buffer = NULL;

libavcodec/get_bits.h:388:9: 
  386.     int buffer_size = (bit_size+7)>>3;
  387.     if (buffer_size < 0 || bit_size < 0) {
  388.         buffer_size = bit_size = 0;
               ^
  389.         buffer = NULL;
  390.     }

libavcodec/get_bits.h:389:9: 
  387.     if (buffer_size < 0 || bit_size < 0) {
  388.         buffer_size = bit_size = 0;
  389.         buffer = NULL;
               ^
  390.     }
  391. 

libavcodec/get_bits.h:392:5: 
  390.     }
  391. 
  392.     s->buffer       = buffer;
           ^
  393.     s->size_in_bits = bit_size;
  394.     s->buffer_end   = buffer + buffer_size;

libavcodec/get_bits.h:393:5: 
  391. 
  392.     s->buffer       = buffer;
  393.     s->size_in_bits = bit_size;
           ^
  394.     s->buffer_end   = buffer + buffer_size;
  395. #ifdef ALT_BITSTREAM_READER

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

libavcodec/get_bits.h:396:5: 
  394.     s->buffer_end   = buffer + buffer_size;
  395. #ifdef ALT_BITSTREAM_READER
  396.     s->index        = 0;
           ^
  397. #elif defined A32_BITSTREAM_READER
  398.     s->buffer_ptr   = (uint32_t*)((intptr_t)buffer & ~3);

libavcodec/get_bits.h:402:1: return from a call to init_get_bits
  400.     skip_bits_long(s, 0);
  401. #endif
  402. }
       ^
  403. 
  404. static inline void align_get_bits(GetBitContext *s)

libavcodec/smacker.c:599:9: 
597.     init_get_bits(&gb, buf + 4, (buf_size - 4) * 8);
598. 
599.     if(!get_bits1(&gb)){
             ^
600.         av_log(avctx, AV_LOG_INFO, "Sound: no data\n");
601.         *data_size = 0;

libavcodec/get_bits.h:303:1: start of procedure get_bits1()
  301. }
  302. 
  303. static inline unsigned int get_bits1(GetBitContext *s){
       ^
  304. #ifdef ALT_BITSTREAM_READER
  305.     unsigned int index = s->index;

libavcodec/get_bits.h:305:5: 
  303. static inline unsigned int get_bits1(GetBitContext *s){
  304. #ifdef ALT_BITSTREAM_READER
  305.     unsigned int index = s->index;
           ^
  306.     uint8_t result = s->buffer[index>>3];
  307. #ifdef ALT_BITSTREAM_READER_LE

libavcodec/get_bits.h:306:5: 
  304. #ifdef ALT_BITSTREAM_READER
  305.     unsigned int index = s->index;
  306.     uint8_t result = s->buffer[index>>3];
           ^
  307. #ifdef ALT_BITSTREAM_READER_LE
  308.     result >>= index & 7;

static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
{
    const uint8_t *buf = avpkt->data;
    int buf_size = avpkt->size;
    GetBitContext gb;
    HuffContext h[4];
    VLC vlc[4];
    int16_t *samples = data;
    uint8_t *samples8 = data;
    int val;
    int i, res;
    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");
        *data_size = 0;
        return 1;
    }
    stereo = get_bits1(&gb);
    bits = get_bits1(&gb);
    if (unp_size & 0xC0000000 || unp_size > *data_size) {
        av_log(avctx, AV_LOG_ERROR, "Frame is too large to fit in buffer\n");
        return -1;
    }
    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);
    }
    memset(vlc, 0, sizeof(VLC) * 4);
    memset(h, 0, sizeof(HuffContext) * 4);
    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));
        skip_bits1(&gb);
        smacker_decode_tree(&gb, &h[i], 0, 0);
        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");
                return -1;
            }
        }
    }
    if(bits) {
        for(i = stereo; i >= 0; i--)
            pred[i] = av_bswap16(get_bits(&gb, 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++ = av_clip_int16(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++ = av_clip_int16(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++ = av_clip_uint8(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++ = av_clip_uint8(pred[0]);
            }
        }
    }
    for(i = 0; i < 4; i++) {
        if(vlc[i].table)
            free_vlc(&vlc[i]);
        av_free(h[i].bits);
        av_free(h[i].lengths);
        av_free(h[i].values);
    }
    *data_size = unp_size;
    return buf_size;
}
['static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)\n{\n    const uint8_t *buf = avpkt->data;\n    int buf_size = avpkt->size;\n    GetBitContext gb;\n    HuffContext h[4];\n    VLC vlc[4];\n    int16_t *samples = data;\n    uint8_t *samples8 = data;\n    int val;\n    int i, res;\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        *data_size = 0;\n        return 1;\n    }\n    stereo = get_bits1(&gb);\n    bits = get_bits1(&gb);\n    if (unp_size & 0xC0000000 || unp_size > *data_size) {\n        av_log(avctx, AV_LOG_ERROR, "Frame is too large to fit in buffer\\n");\n        return -1;\n    }\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    memset(vlc, 0, sizeof(VLC) * 4);\n    memset(h, 0, sizeof(HuffContext) * 4);\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        skip_bits1(&gb);\n        smacker_decode_tree(&gb, &h[i], 0, 0);\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                return -1;\n            }\n        }\n    }\n    if(bits) {\n        for(i = stereo; i >= 0; i--)\n            pred[i] = av_bswap16(get_bits(&gb, 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++ = av_clip_int16(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++ = av_clip_int16(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++ = av_clip_uint8(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++ = av_clip_uint8(pred[0]);\n            }\n        }\n    }\n    for(i = 0; i < 4; i++) {\n        if(vlc[i].table)\n            free_vlc(&vlc[i]);\n        av_free(h[i].bits);\n        av_free(h[i].lengths);\n        av_free(h[i].values);\n    }\n    *data_size = unp_size;\n    return buf_size;\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 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 & 7;\n    result &= 1;\n#else\n    result <<= index & 7;\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}']