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

libavcodec/utils.c:494:1: start of procedure avcodec_default_release_buffer()
492. }
493. 
494. void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic)
     ^
495. {
496.     int i;

libavcodec/utils.c:498:5: 
496.     int i;
497.     InternalBuffer *buf, *last;
498.     AVCodecInternal *avci = s->internal;
         ^
499. 
500.     assert(s->codec_type == AVMEDIA_TYPE_VIDEO);

libavcodec/utils.c:500:5: 
498.     AVCodecInternal *avci = s->internal;
499. 
500.     assert(s->codec_type == AVMEDIA_TYPE_VIDEO);
         ^
501. 
502.     assert(pic->type == FF_BUFFER_TYPE_INTERNAL);

libavcodec/utils.c:502:5: 
500.     assert(s->codec_type == AVMEDIA_TYPE_VIDEO);
501. 
502.     assert(pic->type == FF_BUFFER_TYPE_INTERNAL);
         ^
503.     assert(avci->buffer_count);
504. 

libavcodec/utils.c:503:5: 
501. 
502.     assert(pic->type == FF_BUFFER_TYPE_INTERNAL);
503.     assert(avci->buffer_count);
         ^
504. 
505.     if (avci->buffer) {

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

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

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

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

libavcodec/utils.c:512:9: 
510.                 break;
511.         }
512.         assert(i < avci->buffer_count);
             ^
513.         avci->buffer_count--;
514.         last = &avci->buffer[avci->buffer_count];

libavcodec/utils.c:513:9: 
511.         }
512.         assert(i < avci->buffer_count);
513.         avci->buffer_count--;
             ^
514.         last = &avci->buffer[avci->buffer_count];
515. 

libavcodec/utils.c:514:9: 
512.         assert(i < avci->buffer_count);
513.         avci->buffer_count--;
514.         last = &avci->buffer[avci->buffer_count];
             ^
515. 
516.         if (buf != last)

libavcodec/utils.c:516:13: Taking true branch
514.         last = &avci->buffer[avci->buffer_count];
515. 
516.         if (buf != last)
                 ^
517.             FFSWAP(InternalBuffer, *buf, *last);
518.     }

libavcodec/utils.c:517:13: 
515. 
516.         if (buf != last)
517.             FFSWAP(InternalBuffer, *buf, *last);
                 ^
518.     }
519. 
