libavcodec/utils.c:429: error: Null Dereference
  pointer `desc` last assigned on line 428 could be null and is dereferenced at line 429, column 32.

libavcodec/utils.c:387:1: start of procedure video_get_buffer()
385. }
386. 
387. static int video_get_buffer(AVCodecContext *s, AVFrame *pic)
     ^
388. {
389.     int i;

libavcodec/utils.c:390:5: 
388. {
389.     int i;
390.     int w = s->width;
         ^
391.     int h = s->height;
392.     InternalBuffer *buf;

libavcodec/utils.c:391:5: 
389.     int i;
390.     int w = s->width;
391.     int h = s->height;
         ^
392.     InternalBuffer *buf;
393.     AVCodecInternal *avci = s->internal;

libavcodec/utils.c:393:5: 
391.     int h = s->height;
392.     InternalBuffer *buf;
393.     AVCodecInternal *avci = s->internal;
         ^
394. 
395.     if (pic->data[0] != NULL) {

libavcodec/utils.c:395:9: Taking false branch
393.     AVCodecInternal *avci = s->internal;
394. 
395.     if (pic->data[0] != NULL) {
             ^
396.         av_log(s, AV_LOG_ERROR, "pic->data[0]!=NULL in avcodec_default_get_buffer\n");
397.         return -1;

libavcodec/utils.c:399:9: Taking false branch
397.         return -1;
398.     }
399.     if (avci->buffer_count >= INTERNAL_BUFFER_SIZE) {
             ^
400.         av_log(s, AV_LOG_ERROR, "buffer_count overflow (missing release_buffer?)\n");
401.         return -1;

libavcodec/utils.c:404:9: 
402.     }
403. 
404.     if (av_image_check_size(w, h, 0, s))
             ^
405.         return -1;
406. 

libavutil/imgutils.c:220:1: start of procedure av_image_check_size()
  218. static const AVClass imgutils_class = { "IMGUTILS", av_default_item_name, NULL, LIBAVUTIL_VERSION_INT, offsetof(ImgUtils, log_offset), offsetof(ImgUtils, log_ctx) };
  219. 
  220. int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
       ^
  221. {
  222.     ImgUtils imgutils = { &imgutils_class, log_offset, log_ctx };

libavutil/imgutils.c:222:5: 
  220. int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
  221. {
  222.     ImgUtils imgutils = { &imgutils_class, log_offset, log_ctx };
           ^
  223. 
  224.     if ((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8)

libavutil/imgutils.c:224:9: Taking true branch
  222.     ImgUtils imgutils = { &imgutils_class, log_offset, log_ctx };
  223. 
  224.     if ((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8)
               ^
  225.         return 0;
  226. 

libavutil/imgutils.c:224:21: Taking true branch
  222.     ImgUtils imgutils = { &imgutils_class, log_offset, log_ctx };
  223. 
  224.     if ((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8)
                           ^
  225.         return 0;
  226. 

libavutil/imgutils.c:224:33: Taking true branch
  222.     ImgUtils imgutils = { &imgutils_class, log_offset, log_ctx };
  223. 
  224.     if ((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8)
                                       ^
  225.         return 0;
  226. 

libavutil/imgutils.c:225:9: 
  223. 
  224.     if ((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8)
  225.         return 0;
               ^
  226. 
  227.     av_log(&imgutils, AV_LOG_ERROR, "Picture size %ux%u is invalid\n", w, h);

libavutil/imgutils.c:229:1: return from a call to av_image_check_size
  227.     av_log(&imgutils, AV_LOG_ERROR, "Picture size %ux%u is invalid\n", w, h);
  228.     return AVERROR(EINVAL);
  229. }
       ^
  230. 
  231. void av_image_copy_plane(uint8_t       *dst, int dst_linesize,

libavcodec/utils.c:404:9: Taking false branch
402.     }
403. 
404.     if (av_image_check_size(w, h, 0, s))
             ^
405.         return -1;
406. 

libavcodec/utils.c:407:10: Taking false branch
405.         return -1;
406. 
407.     if (!avci->buffer) {
              ^
408.         avci->buffer = av_mallocz((INTERNAL_BUFFER_SIZE + 1) *
409.                                   sizeof(InternalBuffer));

libavcodec/utils.c:412:5: 
410.     }
411. 
412.     buf = &avci->buffer[avci->buffer_count];
         ^
413. 
414.     if (buf->base[0] && (buf->width != w || buf->height != h || buf->pix_fmt != s->pix_fmt)) {

libavcodec/utils.c:414:9: Taking true branch
412.     buf = &avci->buffer[avci->buffer_count];
413. 
414.     if (buf->base[0] && (buf->width != w || buf->height != h || buf->pix_fmt != s->pix_fmt)) {
             ^
415.         for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {
416.             av_freep(&buf->base[i]);

libavcodec/utils.c:414:26: Taking false branch
412.     buf = &avci->buffer[avci->buffer_count];
413. 
414.     if (buf->base[0] && (buf->width != w || buf->height != h || buf->pix_fmt != s->pix_fmt)) {
                              ^
415.         for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {
416.             av_freep(&buf->base[i]);

libavcodec/utils.c:414:45: Taking true branch
412.     buf = &avci->buffer[avci->buffer_count];
413. 
414.     if (buf->base[0] && (buf->width != w || buf->height != h || buf->pix_fmt != s->pix_fmt)) {
                                                 ^
415.         for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {
416.             av_freep(&buf->base[i]);

libavcodec/utils.c:415:14: 
413. 
414.     if (buf->base[0] && (buf->width != w || buf->height != h || buf->pix_fmt != s->pix_fmt)) {
415.         for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {
                  ^
416.             av_freep(&buf->base[i]);
417.             buf->data[i] = NULL;

libavcodec/utils.c:415:21: Loop condition is true. Entering loop body
413. 
414.     if (buf->base[0] && (buf->width != w || buf->height != h || buf->pix_fmt != s->pix_fmt)) {
415.         for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {
                         ^
416.             av_freep(&buf->base[i]);
417.             buf->data[i] = NULL;

libavcodec/utils.c:416:13: 
414.     if (buf->base[0] && (buf->width != w || buf->height != h || buf->pix_fmt != s->pix_fmt)) {
415.         for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {
416.             av_freep(&buf->base[i]);
                 ^
417.             buf->data[i] = NULL;
418.         }

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

libavutil/mem.c:156:5: 
  154. void av_freep(void *arg)
  155. {
  156.     void **ptr = (void **)arg;
           ^
  157.     av_free(*ptr);
  158.     *ptr = NULL;

libavutil/mem.c:157:5: 
  155. {
  156.     void **ptr = (void **)arg;
  157.     av_free(*ptr);
           ^
  158.     *ptr = NULL;
  159. }

libavutil/mem.c:142:1: start of procedure av_free()
    140. }
    141. 
    142. void av_free(void *ptr)
         ^
    143. {
    144. #if CONFIG_MEMALIGN_HACK

libavutil/mem.c:150:5: 
    148.     _aligned_free(ptr);
    149. #else
    150.     free(ptr);
             ^
    151. #endif
    152. }

libavutil/mem.c:152:1: return from a call to av_free
    150.     free(ptr);
    151. #endif
    152. }
         ^
    153. 
    154. void av_freep(void *arg)

libavutil/mem.c:158:5: 
  156.     void **ptr = (void **)arg;
  157.     av_free(*ptr);
  158.     *ptr = NULL;
           ^
  159. }
  160. 

libavutil/mem.c:159:1: return from a call to av_freep
  157.     av_free(*ptr);
  158.     *ptr = NULL;
  159. }
       ^
  160. 
  161. void *av_mallocz(size_t size)

libavcodec/utils.c:417:13: 
415.         for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {
416.             av_freep(&buf->base[i]);
417.             buf->data[i] = NULL;
                 ^
418.         }
419.     }

libavcodec/utils.c:415:47: 
413. 
414.     if (buf->base[0] && (buf->width != w || buf->height != h || buf->pix_fmt != s->pix_fmt)) {
415.         for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {
                                                   ^
416.             av_freep(&buf->base[i]);
417.             buf->data[i] = NULL;

libavcodec/utils.c:415:21: Loop condition is false. Leaving loop
413. 
414.     if (buf->base[0] && (buf->width != w || buf->height != h || buf->pix_fmt != s->pix_fmt)) {
415.         for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {
                         ^
416.             av_freep(&buf->base[i]);
417.             buf->data[i] = NULL;

libavcodec/utils.c:421:10: Taking true branch
419.     }
420. 
421.     if (!buf->base[0]) {
              ^
422.         int h_chroma_shift, v_chroma_shift;
423.         int size[4] = { 0 };

libavcodec/utils.c:423:9: 
421.     if (!buf->base[0]) {
422.         int h_chroma_shift, v_chroma_shift;
423.         int size[4] = { 0 };
             ^
424.         int tmpsize;
425.         int unaligned;

libavcodec/utils.c:428:9: 
426.         AVPicture picture;
427.         int stride_align[AV_NUM_DATA_POINTERS];
428.         const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->pix_fmt);
             ^
429.         const int pixel_size = desc->comp[0].step_minus1 + 1;
430. 

libavutil/pixdesc.c:1199:1: start of procedure av_pix_fmt_desc_get()
  1197. }
  1198. 
  1199. const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
        ^
  1200. {
  1201.     if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)

libavutil/pixdesc.c:1201:9: Taking false branch
  1199. const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
  1200. {
  1201.     if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)
                ^
  1202.         return NULL;
  1203.     return &av_pix_fmt_descriptors[pix_fmt];

libavutil/pixdesc.c:1201:24: Taking true branch
  1199. const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
  1200. {
  1201.     if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)
                               ^
  1202.         return NULL;
  1203.     return &av_pix_fmt_descriptors[pix_fmt];

libavutil/pixdesc.c:1202:9: 
  1200. {
  1201.     if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)
  1202.         return NULL;
                ^
  1203.     return &av_pix_fmt_descriptors[pix_fmt];
  1204. }

libavutil/pixdesc.c:1204:1: return from a call to av_pix_fmt_desc_get
  1202.         return NULL;
  1203.     return &av_pix_fmt_descriptors[pix_fmt];
  1204. }
        ^
  1205. 
  1206. const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)

libavcodec/utils.c:429:9: 
427.         int stride_align[AV_NUM_DATA_POINTERS];
428.         const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->pix_fmt);
429.         const int pixel_size = desc->comp[0].step_minus1 + 1;
             ^
430. 
431.         avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift);

static int video_get_buffer(AVCodecContext *s, AVFrame *pic)
{
    int i;
    int w = s->width;
    int h = s->height;
    InternalBuffer *buf;
    AVCodecInternal *avci = s->internal;
    if (pic->data[0] != NULL) {
        av_log(s, AV_LOG_ERROR, "pic->data[0]!=NULL in avcodec_default_get_buffer\n");
        return -1;
    }
    if (avci->buffer_count >= INTERNAL_BUFFER_SIZE) {
        av_log(s, AV_LOG_ERROR, "buffer_count overflow (missing release_buffer?)\n");
        return -1;
    }
    if (av_image_check_size(w, h, 0, s))
        return -1;
    if (!avci->buffer) {
        avci->buffer = av_mallocz((INTERNAL_BUFFER_SIZE + 1) *
                                  sizeof(InternalBuffer));
    }
    buf = &avci->buffer[avci->buffer_count];
    if (buf->base[0] && (buf->width != w || buf->height != h || buf->pix_fmt != s->pix_fmt)) {
        for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {
            av_freep(&buf->base[i]);
            buf->data[i] = NULL;
        }
    }
    if (!buf->base[0]) {
        int h_chroma_shift, v_chroma_shift;
        int size[4] = { 0 };
        int tmpsize;
        int unaligned;
        AVPicture picture;
        int stride_align[AV_NUM_DATA_POINTERS];
        const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->pix_fmt);
        const int pixel_size = desc->comp[0].step_minus1 + 1;
        avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift);
        avcodec_align_dimensions2(s, &w, &h, stride_align);
        if (!(s->flags & CODEC_FLAG_EMU_EDGE)) {
            w += EDGE_WIDTH * 2;
            h += EDGE_WIDTH * 2;
        }
        do {
            av_image_fill_linesizes(picture.linesize, s->pix_fmt, w);
            w += w & ~(w - 1);
            unaligned = 0;
            for (i = 0; i < 4; i++)
                unaligned |= picture.linesize[i] % stride_align[i];
        } while (unaligned);
        tmpsize = av_image_fill_pointers(picture.data, s->pix_fmt, h, NULL, picture.linesize);
        if (tmpsize < 0)
            return -1;
        for (i = 0; i < 3 && picture.data[i + 1]; i++)
            size[i] = picture.data[i + 1] - picture.data[i];
        size[i] = tmpsize - (picture.data[i] - picture.data[0]);
        memset(buf->base, 0, sizeof(buf->base));
        memset(buf->data, 0, sizeof(buf->data));
        for (i = 0; i < 4 && size[i]; i++) {
            const int h_shift = i == 0 ? 0 : h_chroma_shift;
            const int v_shift = i == 0 ? 0 : v_chroma_shift;
            buf->linesize[i] = picture.linesize[i];
            buf->base[i] = av_malloc(size[i] + 16);
            if (buf->base[i] == NULL)
                return -1;
            memset(buf->base[i], 128, size[i]);
            if ((s->flags & CODEC_FLAG_EMU_EDGE) || !size[2])
                buf->data[i] = buf->base[i];
            else
                buf->data[i] = buf->base[i] + FFALIGN((buf->linesize[i] * EDGE_WIDTH >> v_shift) + (pixel_size * EDGE_WIDTH >> h_shift), stride_align[i]);
        }
        for (; i < AV_NUM_DATA_POINTERS; i++) {
            buf->base[i]     = buf->data[i] = NULL;
            buf->linesize[i] = 0;
        }
        if (size[1] && !size[2])
            avpriv_set_systematic_pal2((uint32_t *)buf->data[1], s->pix_fmt);
        buf->width   = s->width;
        buf->height  = s->height;
        buf->pix_fmt = s->pix_fmt;
    }
    pic->type = FF_BUFFER_TYPE_INTERNAL;
    for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {
        pic->base[i]     = buf->base[i];
        pic->data[i]     = buf->data[i];
        pic->linesize[i] = buf->linesize[i];
    }
    pic->extended_data = pic->data;
    avci->buffer_count++;
    pic->width               = buf->width;
    pic->height              = buf->height;
    pic->format              = buf->pix_fmt;
    pic->sample_aspect_ratio = s->sample_aspect_ratio;
    if (s->pkt)
        pic->pkt_pts = s->pkt->pts;
    else
        pic->pkt_pts = AV_NOPTS_VALUE;
    pic->reordered_opaque = s->reordered_opaque;
    if (s->debug & FF_DEBUG_BUFFERS)
        av_log(s, AV_LOG_DEBUG, "default_get_buffer called on pic %p, %d "
                                "buffers used\n", pic, avci->buffer_count);
    return 0;
}
['static int video_get_buffer(AVCodecContext *s, AVFrame *pic)\n{\n    int i;\n    int w = s->width;\n    int h = s->height;\n    InternalBuffer *buf;\n    AVCodecInternal *avci = s->internal;\n    if (pic->data[0] != NULL) {\n        av_log(s, AV_LOG_ERROR, "pic->data[0]!=NULL in avcodec_default_get_buffer\\n");\n        return -1;\n    }\n    if (avci->buffer_count >= INTERNAL_BUFFER_SIZE) {\n        av_log(s, AV_LOG_ERROR, "buffer_count overflow (missing release_buffer?)\\n");\n        return -1;\n    }\n    if (av_image_check_size(w, h, 0, s))\n        return -1;\n    if (!avci->buffer) {\n        avci->buffer = av_mallocz((INTERNAL_BUFFER_SIZE + 1) *\n                                  sizeof(InternalBuffer));\n    }\n    buf = &avci->buffer[avci->buffer_count];\n    if (buf->base[0] && (buf->width != w || buf->height != h || buf->pix_fmt != s->pix_fmt)) {\n        for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {\n            av_freep(&buf->base[i]);\n            buf->data[i] = NULL;\n        }\n    }\n    if (!buf->base[0]) {\n        int h_chroma_shift, v_chroma_shift;\n        int size[4] = { 0 };\n        int tmpsize;\n        int unaligned;\n        AVPicture picture;\n        int stride_align[AV_NUM_DATA_POINTERS];\n        const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->pix_fmt);\n        const int pixel_size = desc->comp[0].step_minus1 + 1;\n        avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift);\n        avcodec_align_dimensions2(s, &w, &h, stride_align);\n        if (!(s->flags & CODEC_FLAG_EMU_EDGE)) {\n            w += EDGE_WIDTH * 2;\n            h += EDGE_WIDTH * 2;\n        }\n        do {\n            av_image_fill_linesizes(picture.linesize, s->pix_fmt, w);\n            w += w & ~(w - 1);\n            unaligned = 0;\n            for (i = 0; i < 4; i++)\n                unaligned |= picture.linesize[i] % stride_align[i];\n        } while (unaligned);\n        tmpsize = av_image_fill_pointers(picture.data, s->pix_fmt, h, NULL, picture.linesize);\n        if (tmpsize < 0)\n            return -1;\n        for (i = 0; i < 3 && picture.data[i + 1]; i++)\n            size[i] = picture.data[i + 1] - picture.data[i];\n        size[i] = tmpsize - (picture.data[i] - picture.data[0]);\n        memset(buf->base, 0, sizeof(buf->base));\n        memset(buf->data, 0, sizeof(buf->data));\n        for (i = 0; i < 4 && size[i]; i++) {\n            const int h_shift = i == 0 ? 0 : h_chroma_shift;\n            const int v_shift = i == 0 ? 0 : v_chroma_shift;\n            buf->linesize[i] = picture.linesize[i];\n            buf->base[i] = av_malloc(size[i] + 16);\n            if (buf->base[i] == NULL)\n                return -1;\n            memset(buf->base[i], 128, size[i]);\n            if ((s->flags & CODEC_FLAG_EMU_EDGE) || !size[2])\n                buf->data[i] = buf->base[i];\n            else\n                buf->data[i] = buf->base[i] + FFALIGN((buf->linesize[i] * EDGE_WIDTH >> v_shift) + (pixel_size * EDGE_WIDTH >> h_shift), stride_align[i]);\n        }\n        for (; i < AV_NUM_DATA_POINTERS; i++) {\n            buf->base[i]     = buf->data[i] = NULL;\n            buf->linesize[i] = 0;\n        }\n        if (size[1] && !size[2])\n            avpriv_set_systematic_pal2((uint32_t *)buf->data[1], s->pix_fmt);\n        buf->width   = s->width;\n        buf->height  = s->height;\n        buf->pix_fmt = s->pix_fmt;\n    }\n    pic->type = FF_BUFFER_TYPE_INTERNAL;\n    for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {\n        pic->base[i]     = buf->base[i];\n        pic->data[i]     = buf->data[i];\n        pic->linesize[i] = buf->linesize[i];\n    }\n    pic->extended_data = pic->data;\n    avci->buffer_count++;\n    pic->width               = buf->width;\n    pic->height              = buf->height;\n    pic->format              = buf->pix_fmt;\n    pic->sample_aspect_ratio = s->sample_aspect_ratio;\n    if (s->pkt)\n        pic->pkt_pts = s->pkt->pts;\n    else\n        pic->pkt_pts = AV_NOPTS_VALUE;\n    pic->reordered_opaque = s->reordered_opaque;\n    if (s->debug & FF_DEBUG_BUFFERS)\n        av_log(s, AV_LOG_DEBUG, "default_get_buffer called on pic %p, %d "\n                                "buffers used\\n", pic, avci->buffer_count);\n    return 0;\n}', 'int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)\n{\n    ImgUtils imgutils = { &imgutils_class, log_offset, log_ctx };\n    if ((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8)\n        return 0;\n    av_log(&imgutils, AV_LOG_ERROR, "Picture size %ux%u is invalid\\n", w, h);\n    return AVERROR(EINVAL);\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 CONFIG_MEMALIGN_HACK\n    if (ptr)\n        free((char *)ptr - ((char *)ptr)[-1]);\n#elif HAVE_ALIGNED_MALLOC\n    _aligned_free(ptr);\n#else\n    free(ptr);\n#endif\n}', 'const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)\n{\n    if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)\n        return NULL;\n    return &av_pix_fmt_descriptors[pix_fmt];\n}']