libavformat/hlsenc.c:331: error: Use After Free
  call to `append_entry()` eventually accesses memory that was invalidated by call to `free()` on line 329 indirectly during the call to `avformat_free_context()`.

libavformat/hlsenc.c:322:1: invalidation part of the trace starts here
320. }
321. 
322. static int hls_write_trailer(struct AVFormatContext *s)
     ^
323. {
324.     HLSContext *hls = s->priv_data;

libavformat/hlsenc.c:322:1: parameter `s` of hls_write_trailer
  320. }
  321. 
  322. static int hls_write_trailer(struct AVFormatContext *s)
       ^
  323. {
  324.     HLSContext *hls = s->priv_data;

libavformat/hlsenc.c:324:5: assigned
  322. static int hls_write_trailer(struct AVFormatContext *s)
  323. {
  324.     HLSContext *hls = s->priv_data;
           ^
  325.     AVFormatContext *oc = hls->avf;
  326. 

libavformat/hlsenc.c:325:5: assigned
  323. {
  324.     HLSContext *hls = s->priv_data;
  325.     AVFormatContext *oc = hls->avf;
           ^
  326. 
  327.     av_write_trailer(oc);

libavformat/hlsenc.c:329:5: when calling `avformat_free_context` here
  327.     av_write_trailer(oc);
  328.     ff_format_io_close(s, &oc->pb);
  329.     avformat_free_context(oc);
           ^
  330.     av_free(hls->basename);
  331.     append_entry(hls, hls->duration);

libavformat/utils.c:2477:1: parameter `s` of avformat_free_context
    2475. }
    2476. 
    2477. void avformat_free_context(AVFormatContext *s)
          ^
    2478. {
    2479.     int i;

libavformat/utils.c:2506:5: when calling `av_free` here
    2504.     av_freep(&s->streams);
    2505.     av_freep(&s->internal);
    2506.     av_free(s);
              ^
    2507. }
    2508. 

libavutil/mem.c:190:1: parameter `ptr` of av_free
      188. }
      189. 
      190. void av_free(void *ptr)
           ^
      191. {
      192. #if CONFIG_MEMALIGN_HACK

libavutil/mem.c:198:5: was invalidated by call to `free()`
      196.     _aligned_free(ptr);
      197. #else
      198.     free(ptr);
               ^
      199. #endif
      200. }

libavformat/hlsenc.c:322:1: use-after-lifetime part of the trace starts here
320. }
321. 
322. static int hls_write_trailer(struct AVFormatContext *s)
     ^
323. {
324.     HLSContext *hls = s->priv_data;

libavformat/hlsenc.c:322:1: parameter `s` of hls_write_trailer
  320. }
  321. 
  322. static int hls_write_trailer(struct AVFormatContext *s)
       ^
  323. {
  324.     HLSContext *hls = s->priv_data;

libavformat/hlsenc.c:324:5: assigned
  322. static int hls_write_trailer(struct AVFormatContext *s)
  323. {
  324.     HLSContext *hls = s->priv_data;
           ^
  325.     AVFormatContext *oc = hls->avf;
  326. 

libavformat/hlsenc.c:331:5: when calling `append_entry` here
  329.     avformat_free_context(oc);
  330.     av_free(hls->basename);
  331.     append_entry(hls, hls->duration);
           ^
  332.     hls_window(s, 1);
  333. 

libavformat/hlsenc.c:93:1: parameter `hls` of append_entry
    91. }
    92. 
    93. static int append_entry(HLSContext *hls, int64_t duration)
        ^
    94. {
    95.     ListEntry *en = av_malloc(sizeof(*en));

libavformat/hlsenc.c:100:26: invalid access occurs here
     98.         return AVERROR(ENOMEM);
     99. 
    100.     av_strlcpy(en->name, av_basename(hls->avf->filename), sizeof(en->name));
                                  ^
    101. 
    102.     en->duration = duration;
