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

libavcodec/utils.c:378:1: start of procedure avcodec_default_release_buffer()
376. }
377. 
378. void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){
     ^
379.     int i;
380.     InternalBuffer *buf, *last;

libavcodec/utils.c:382:5: 
380.     InternalBuffer *buf, *last;
381. 
382.     assert(pic->type==FF_BUFFER_TYPE_INTERNAL);
         ^
383.     assert(s->internal_buffer_count);
384. 

libavcodec/utils.c:383:5: 
381. 
382.     assert(pic->type==FF_BUFFER_TYPE_INTERNAL);
383.     assert(s->internal_buffer_count);
         ^
384. 
385.     if(s->internal_buffer){

libavcodec/utils.c:385:8: Taking true branch
383.     assert(s->internal_buffer_count);
384. 
385.     if(s->internal_buffer){
            ^
386.     buf = NULL; /* avoids warning */
387.     for(i=0; i<s->internal_buffer_count; i++){ //just 3-5 checks so is not worth to optimize

libavcodec/utils.c:386:5: 
384. 
385.     if(s->internal_buffer){
386.     buf = NULL; /* avoids warning */
         ^
387.     for(i=0; i<s->internal_buffer_count; i++){ //just 3-5 checks so is not worth to optimize
388.         buf= &((InternalBuffer*)s->internal_buffer)[i];

libavcodec/utils.c:387:9: 
385.     if(s->internal_buffer){
386.     buf = NULL; /* avoids warning */
387.     for(i=0; i<s->internal_buffer_count; i++){ //just 3-5 checks so is not worth to optimize
             ^
388.         buf= &((InternalBuffer*)s->internal_buffer)[i];
389.         if(buf->data[0] == pic->data[0])

libavcodec/utils.c:387:14: Loop condition is false. Leaving loop
385.     if(s->internal_buffer){
386.     buf = NULL; /* avoids warning */
387.     for(i=0; i<s->internal_buffer_count; i++){ //just 3-5 checks so is not worth to optimize
                  ^
388.         buf= &((InternalBuffer*)s->internal_buffer)[i];
389.         if(buf->data[0] == pic->data[0])

libavcodec/utils.c:392:5: 
390.             break;
391.     }
392.     assert(i < s->internal_buffer_count);
         ^
393.     s->internal_buffer_count--;
394.     last = &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count];

libavcodec/utils.c:393:5: 
391.     }
392.     assert(i < s->internal_buffer_count);
393.     s->internal_buffer_count--;
         ^
394.     last = &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count];
395. 

libavcodec/utils.c:394:5: 
392.     assert(i < s->internal_buffer_count);
393.     s->internal_buffer_count--;
394.     last = &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count];
         ^
395. 
396.     FFSWAP(InternalBuffer, *buf, *last);

libavcodec/utils.c:396:5: 
394.     last = &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count];
395. 
396.     FFSWAP(InternalBuffer, *buf, *last);
         ^
397.     }
398. 

void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){
    int i;
    InternalBuffer *buf, *last;
    assert(pic->type==FF_BUFFER_TYPE_INTERNAL);
    assert(s->internal_buffer_count);
    if(s->internal_buffer){
    buf = NULL;
    for(i=0; i<s->internal_buffer_count; i++){
        buf= &((InternalBuffer*)s->internal_buffer)[i];
        if(buf->data[0] == pic->data[0])
            break;
    }
    assert(i < s->internal_buffer_count);
    s->internal_buffer_count--;
    last = &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count];
    FFSWAP(InternalBuffer, *buf, *last);
    }
    for(i=0; i<4; 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, s->internal_buffer_count);
}
['void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){\n    int i;\n    InternalBuffer *buf, *last;\n    assert(pic->type==FF_BUFFER_TYPE_INTERNAL);\n    assert(s->internal_buffer_count);\n    if(s->internal_buffer){\n    buf = NULL;\n    for(i=0; i<s->internal_buffer_count; i++){\n        buf= &((InternalBuffer*)s->internal_buffer)[i];\n        if(buf->data[0] == pic->data[0])\n            break;\n    }\n    assert(i < s->internal_buffer_count);\n    s->internal_buffer_count--;\n    last = &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count];\n    FFSWAP(InternalBuffer, *buf, *last);\n    }\n    for(i=0; i<4; 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 buffers used\\n", pic, s->internal_buffer_count);\n}']