libavcodec/utils.c:529: error: Null Dereference
  pointer `buf` last assigned on line 518 could be null and is dereferenced at line 529, column 13.

libavcodec/utils.c:507:1: start of procedure avcodec_default_release_buffer()
505. }
506. 
507. void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){
     ^
508.     int i;
509.     InternalBuffer *buf, *last;

libavcodec/utils.c:510:5: 
508.     int i;
509.     InternalBuffer *buf, *last;
510.     AVCodecInternal *avci = s->internal;
         ^
511. 
512.     assert(s->codec_type == AVMEDIA_TYPE_VIDEO);

libavcodec/utils.c:512:5: 
510.     AVCodecInternal *avci = s->internal;
511. 
512.     assert(s->codec_type == AVMEDIA_TYPE_VIDEO);
         ^
513. 
514.     assert(pic->type==FF_BUFFER_TYPE_INTERNAL);

libavcodec/utils.c:514:5: 
512.     assert(s->codec_type == AVMEDIA_TYPE_VIDEO);
513. 
514.     assert(pic->type==FF_BUFFER_TYPE_INTERNAL);
         ^
515.     assert(avci->buffer_count);
516. 

libavcodec/utils.c:515:5: 
513. 
514.     assert(pic->type==FF_BUFFER_TYPE_INTERNAL);
515.     assert(avci->buffer_count);
         ^
516. 
517.     if (avci->buffer) {

libavcodec/utils.c:517:9: Taking true branch
515.     assert(avci->buffer_count);
516. 
517.     if (avci->buffer) {
             ^
518.         buf = NULL; /* avoids warning */
519.         for (i = 0; i < avci->buffer_count; i++) { //just 3-5 checks so is not worth to optimize

libavcodec/utils.c:518:9: 
516. 
517.     if (avci->buffer) {
518.         buf = NULL; /* avoids warning */
             ^
519.         for (i = 0; i < avci->buffer_count; i++) { //just 3-5 checks so is not worth to optimize
520.             buf = &avci->buffer[i];

libavcodec/utils.c:519:14: 
517.     if (avci->buffer) {
518.         buf = NULL; /* avoids warning */
519.         for (i = 0; i < avci->buffer_count; i++) { //just 3-5 checks so is not worth to optimize
                  ^
520.             buf = &avci->buffer[i];
521.             if (buf->data[0] == pic->data[0])

libavcodec/utils.c:519:21: Loop condition is false. Leaving loop
517.     if (avci->buffer) {
518.         buf = NULL; /* avoids warning */
519.         for (i = 0; i < avci->buffer_count; i++) { //just 3-5 checks so is not worth to optimize
                         ^
520.             buf = &avci->buffer[i];
521.             if (buf->data[0] == pic->data[0])

libavcodec/utils.c:524:9: 
522.                 break;
523.         }
524.         assert(i < avci->buffer_count);
             ^
525.         avci->buffer_count--;
526.         last = &avci->buffer[avci->buffer_count];

libavcodec/utils.c:525:9: 
523.         }
524.         assert(i < avci->buffer_count);
525.         avci->buffer_count--;
             ^
526.         last = &avci->buffer[avci->buffer_count];
527. 

libavcodec/utils.c:526:9: 
524.         assert(i < avci->buffer_count);
525.         avci->buffer_count--;
526.         last = &avci->buffer[avci->buffer_count];
             ^
527. 
528.         if (buf != last)

libavcodec/utils.c:528:13: Taking true branch
526.         last = &avci->buffer[avci->buffer_count];
527. 
528.         if (buf != last)
                 ^
529.             FFSWAP(InternalBuffer, *buf, *last);
530.     }

libavcodec/utils.c:529:13: 
527. 
528.         if (buf != last)
529.             FFSWAP(InternalBuffer, *buf, *last);
                 ^
530.     }
531. 

void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){
    int i;
    InternalBuffer *buf, *last;
    AVCodecInternal *avci = s->internal;
    assert(s->codec_type == AVMEDIA_TYPE_VIDEO);
    assert(pic->type==FF_BUFFER_TYPE_INTERNAL);
    assert(avci->buffer_count);
    if (avci->buffer) {
        buf = NULL;
        for (i = 0; i < avci->buffer_count; i++) {
            buf = &avci->buffer[i];
            if (buf->data[0] == pic->data[0])
                break;
        }
        assert(i < avci->buffer_count);
        avci->buffer_count--;
        last = &avci->buffer[avci->buffer_count];
        if (buf != last)
            FFSWAP(InternalBuffer, *buf, *last);
    }
    for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {
        pic->data[i]=NULL;
    }
    if(s->debug&FF_DEBUG_BUFFERS)
        av_log(s, AV_LOG_DEBUG, "default_release_buffer called on pic %p, %d "
               "buffers used\n", pic, avci->buffer_count);
}
['void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){\n    int i;\n    InternalBuffer *buf, *last;\n    AVCodecInternal *avci = s->internal;\n    assert(s->codec_type == AVMEDIA_TYPE_VIDEO);\n    assert(pic->type==FF_BUFFER_TYPE_INTERNAL);\n    assert(avci->buffer_count);\n    if (avci->buffer) {\n        buf = NULL;\n        for (i = 0; i < avci->buffer_count; i++) {\n            buf = &avci->buffer[i];\n            if (buf->data[0] == pic->data[0])\n                break;\n        }\n        assert(i < avci->buffer_count);\n        avci->buffer_count--;\n        last = &avci->buffer[avci->buffer_count];\n        if (buf != last)\n            FFSWAP(InternalBuffer, *buf, *last);\n    }\n    for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {\n        pic->data[i]=NULL;\n    }\n    if(s->debug&FF_DEBUG_BUFFERS)\n        av_log(s, AV_LOG_DEBUG, "default_release_buffer called on pic %p, %d "\n               "buffers used\\n", pic, avci->buffer_count);\n}']