libavcodec/utils.c:317: error: Use After Free
  accessing memory that was invalidated by call to `free()` on line 316 indirectly during the call to `av_free()`.

libavcodec/utils.c:303:24: invalidation part of the trace starts here
301.     /* allocate InternalBuffer if needed */
302.     if (!avci->buffer) {
303.         avci->buffer = av_mallocz(sizeof(InternalBuffer));
                            ^
304.         if (!avci->buffer)
305.             return AVERROR(ENOMEM);

libavcodec/utils.c:303:24: passed as argument to `av_mallocz`
  301.     /* allocate InternalBuffer if needed */
  302.     if (!avci->buffer) {
  303.         avci->buffer = av_mallocz(sizeof(InternalBuffer));
                              ^
  304.         if (!avci->buffer)
  305.             return AVERROR(ENOMEM);

libavcodec/utils.c:303:24: return from call to `av_mallocz`
  301.     /* allocate InternalBuffer if needed */
  302.     if (!avci->buffer) {
  303.         avci->buffer = av_mallocz(sizeof(InternalBuffer));
                              ^
  304.         if (!avci->buffer)
  305.             return AVERROR(ENOMEM);

libavcodec/utils.c:303:9: assigned
  301.     /* allocate InternalBuffer if needed */
  302.     if (!avci->buffer) {
  303.         avci->buffer = av_mallocz(sizeof(InternalBuffer));
               ^
  304.         if (!avci->buffer)
  305.             return AVERROR(ENOMEM);

libavcodec/utils.c:307:5: assigned
  305.             return AVERROR(ENOMEM);
  306.     }
  307.     buf = avci->buffer;
           ^
  308. 
  309.     /* if there is a previously-used internal buffer, check its size and

libavcodec/utils.c:316:17: when calling `av_free` here
  314.             av_free(buf->extended_data[0]);
  315.             if (buf->extended_data != buf->data)
  316.                 av_free(&buf->extended_data);
                       ^
  317.             buf->extended_data = NULL;
  318.             buf->data[0] = NULL;

libavutil/mem.c:137:1: parameter `ptr` of av_free
    135. }
    136. 
    137. void av_free(void *ptr)
         ^
    138. {
    139. #if CONFIG_MEMALIGN_HACK

libavutil/mem.c:143:5: was invalidated by call to `free()`
    141.         free((char*)ptr - ((char*)ptr)[-1]);
    142. #else
    143.     free(ptr);
             ^
    144. #endif
    145. }

libavcodec/utils.c:303:24: use-after-lifetime part of the trace starts here
301.     /* allocate InternalBuffer if needed */
302.     if (!avci->buffer) {
303.         avci->buffer = av_mallocz(sizeof(InternalBuffer));
                            ^
304.         if (!avci->buffer)
305.             return AVERROR(ENOMEM);

libavcodec/utils.c:303:24: passed as argument to `av_mallocz`
  301.     /* allocate InternalBuffer if needed */
  302.     if (!avci->buffer) {
  303.         avci->buffer = av_mallocz(sizeof(InternalBuffer));
                              ^
  304.         if (!avci->buffer)
  305.             return AVERROR(ENOMEM);

libavcodec/utils.c:303:24: return from call to `av_mallocz`
  301.     /* allocate InternalBuffer if needed */
  302.     if (!avci->buffer) {
  303.         avci->buffer = av_mallocz(sizeof(InternalBuffer));
                              ^
  304.         if (!avci->buffer)
  305.             return AVERROR(ENOMEM);

libavcodec/utils.c:303:9: assigned
  301.     /* allocate InternalBuffer if needed */
  302.     if (!avci->buffer) {
  303.         avci->buffer = av_mallocz(sizeof(InternalBuffer));
               ^
  304.         if (!avci->buffer)
  305.             return AVERROR(ENOMEM);

libavcodec/utils.c:307:5: assigned
  305.             return AVERROR(ENOMEM);
  306.     }
  307.     buf = avci->buffer;
           ^
  308. 
  309.     /* if there is a previously-used internal buffer, check its size and

libavcodec/utils.c:317:13: invalid access occurs here
  315.             if (buf->extended_data != buf->data)
  316.                 av_free(&buf->extended_data);
  317.             buf->extended_data = NULL;
                   ^
  318.             buf->data[0] = NULL;
  319.         }
