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

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

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

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

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

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

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

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

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:403:9: Taking false branch
401.     }
402. 
403.     if (av_image_check_size(w, h, 0, s))
             ^
404.         return -1;
405. 

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

libavutil/pixdesc.c:1433:1: start of procedure av_pix_fmt_desc_get()
  1431. }
  1432. 
  1433. const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
        ^
  1434. {
  1435.     if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)

libavutil/pixdesc.c:1435:9: Taking false branch
  1433. const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
  1434. {
  1435.     if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)
                ^
  1436.         return NULL;
  1437.     return &av_pix_fmt_descriptors[pix_fmt];

libavutil/pixdesc.c:1435:24: Taking true branch
  1433. const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
  1434. {
  1435.     if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)
                               ^
  1436.         return NULL;
  1437.     return &av_pix_fmt_descriptors[pix_fmt];

libavutil/pixdesc.c:1436:9: 
  1434. {
  1435.     if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)
  1436.         return NULL;
                ^
  1437.     return &av_pix_fmt_descriptors[pix_fmt];
  1438. }

libavutil/pixdesc.c:1438:1: return from a call to av_pix_fmt_desc_get
  1436.         return NULL;
  1437.     return &av_pix_fmt_descriptors[pix_fmt];
  1438. }
        ^
  1439. 
  1440. const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)

libavcodec/utils.c:428:9: 
426.         int stride_align[AV_NUM_DATA_POINTERS];
427.         const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->pix_fmt);
428.         const int pixel_size = desc->comp[0].step_minus1 + 1;
             ^
429. 
430.         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}']