libavfilter/buffersrc.c:387: error: Use After Free
  accessing memory that was invalidated by call to `free()` on line 386 indirectly during the call to `ff_add_channel_layout()`.

libavfilter/buffersrc.c:370:5: invalidation part of the trace starts here
368. {
369.     BufferSourceContext *c = ctx->priv;
370.     AVFilterChannelLayouts *channel_layouts = NULL;
         ^
371.     AVFilterFormats *formats = NULL;
372.     AVFilterFormats *samplerates = NULL;

libavfilter/buffersrc.c:370:5: variable `channel_layouts` declared here
  368. {
  369.     BufferSourceContext *c = ctx->priv;
  370.     AVFilterChannelLayouts *channel_layouts = NULL;
           ^
  371.     AVFilterFormats *formats = NULL;
  372.     AVFilterFormats *samplerates = NULL;

libavfilter/buffersrc.c:386:9: when calling `ff_add_channel_layout` here
  384.         ff_set_common_samplerates(ctx, samplerates);
  385. 
  386.         ff_add_channel_layout(&channel_layouts, c->channel_layout);
               ^
  387.         ff_set_common_channel_layouts(ctx, channel_layouts);
  388.         break;

libavfilter/formats.c:206:1: parameter `l` of ff_add_channel_layout
    204. }
    205. 
    206. int ff_add_channel_layout(AVFilterChannelLayouts **l, uint64_t channel_layout)
         ^
    207. {
    208.     ADD_FORMAT(l, channel_layout, uint64_t, channel_layouts, nb_channel_layouts);

libavfilter/formats.c:208:5: when calling `av_freep` here
    206. int ff_add_channel_layout(AVFilterChannelLayouts **l, uint64_t channel_layout)
    207. {
    208.     ADD_FORMAT(l, channel_layout, uint64_t, channel_layouts, nb_channel_layouts);
             ^
    209. }
    210. 

libavutil/mem.c:198:1: parameter `arg` of av_freep
      196. }
      197. 
      198. void av_freep(void *arg)
           ^
      199. {
      200.     void **ptr = (void **)arg;

libavutil/mem.c:200:5: assigned
      198. void av_freep(void *arg)
      199. {
      200.     void **ptr = (void **)arg;
               ^
      201.     av_free(*ptr);
      202.     *ptr = NULL;

libavutil/mem.c:201:5: when calling `av_free` here
      199. {
      200.     void **ptr = (void **)arg;
      201.     av_free(*ptr);
               ^
      202.     *ptr = NULL;
      203. }

libavutil/mem.c:186:1: parameter `ptr` of av_free
        184. }
        185. 
        186. void av_free(void *ptr)
             ^
        187. {
        188. #if CONFIG_MEMALIGN_HACK

libavutil/mem.c:194:5: was invalidated by call to `free()`
        192.     _aligned_free(ptr);
        193. #else
        194.     free(ptr);
                 ^
        195. #endif
        196. }

libavfilter/buffersrc.c:370:5: use-after-lifetime part of the trace starts here
368. {
369.     BufferSourceContext *c = ctx->priv;
370.     AVFilterChannelLayouts *channel_layouts = NULL;
         ^
371.     AVFilterFormats *formats = NULL;
372.     AVFilterFormats *samplerates = NULL;

libavfilter/buffersrc.c:370:5: variable `channel_layouts` declared here
  368. {
  369.     BufferSourceContext *c = ctx->priv;
  370.     AVFilterChannelLayouts *channel_layouts = NULL;
           ^
  371.     AVFilterFormats *formats = NULL;
  372.     AVFilterFormats *samplerates = NULL;

libavfilter/buffersrc.c:387:44: invalid access occurs here
  385. 
  386.         ff_add_channel_layout(&channel_layouts, c->channel_layout);
  387.         ff_set_common_channel_layouts(ctx, channel_layouts);
                                                  ^
  388.         break;
  389.     default:
