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

libavformat/hlsenc.c:498:1: invalidation part of the trace starts here
496. }
497. 
498. static int hls_write_trailer(struct AVFormatContext *s)
     ^
499. {
500.     HLSContext *hls = s->priv_data;

libavformat/hlsenc.c:498:1: parameter `s` of hls_write_trailer
  496. }
  497. 
  498. static int hls_write_trailer(struct AVFormatContext *s)
       ^
  499. {
  500.     HLSContext *hls = s->priv_data;

libavformat/hlsenc.c:500:5: assigned
  498. static int hls_write_trailer(struct AVFormatContext *s)
  499. {
  500.     HLSContext *hls = s->priv_data;
           ^
  501.     AVFormatContext *oc = hls->avf;
  502. 

libavformat/hlsenc.c:501:5: assigned
  499. {
  500.     HLSContext *hls = s->priv_data;
  501.     AVFormatContext *oc = hls->avf;
           ^
  502. 
  503.     av_write_trailer(oc);

libavformat/hlsenc.c:505:5: when calling `avformat_free_context` here
  503.     av_write_trailer(oc);
  504.     ff_format_io_close(s, &oc->pb);
  505.     avformat_free_context(oc);
           ^
  506.     av_free(hls->basename);
  507.     append_entry(hls, hls->duration);

libavformat/utils.c:2705:1: parameter `s` of avformat_free_context
    2703. }
    2704. 
    2705. void avformat_free_context(AVFormatContext *s)
          ^
    2706. {
    2707.     int i;

libavformat/utils.c:2734:5: when calling `av_free` here
    2732.     av_freep(&s->streams);
    2733.     av_freep(&s->internal);
    2734.     av_free(s);
              ^
    2735. }
    2736. 

libavutil/mem.c:170:1: parameter `ptr` of av_free
      168. }
      169. 
      170. void av_free(void *ptr)
           ^
      171. {
      172. #if HAVE_ALIGNED_MALLOC

libavutil/mem.c:175:5: was invalidated by call to `free()`
      173.     _aligned_free(ptr);
      174. #else
      175.     free(ptr);
               ^
      176. #endif
      177. }

libavformat/hlsenc.c:498:1: use-after-lifetime part of the trace starts here
496. }
497. 
498. static int hls_write_trailer(struct AVFormatContext *s)
     ^
499. {
500.     HLSContext *hls = s->priv_data;

libavformat/hlsenc.c:498:1: parameter `s` of hls_write_trailer
  496. }
  497. 
  498. static int hls_write_trailer(struct AVFormatContext *s)
       ^
  499. {
  500.     HLSContext *hls = s->priv_data;

libavformat/hlsenc.c:500:5: assigned
  498. static int hls_write_trailer(struct AVFormatContext *s)
  499. {
  500.     HLSContext *hls = s->priv_data;
           ^
  501.     AVFormatContext *oc = hls->avf;
  502. 

libavformat/hlsenc.c:507:5: when calling `append_entry` here
  505.     avformat_free_context(oc);
  506.     av_free(hls->basename);
  507.     append_entry(hls, hls->duration);
           ^
  508.     hls_window(s, 1);
  509. 

libavformat/hlsenc.c:208:1: parameter `hls` of append_entry
    206. }
    207. 
    208. static int append_entry(HLSContext *hls, int64_t duration)
         ^
    209. {
    210.     ListEntry *en = av_malloc(sizeof(*en));

libavformat/hlsenc.c:215:26: invalid access occurs here
    213.         return AVERROR(ENOMEM);
    214. 
    215.     av_strlcpy(en->name, av_basename(hls->avf->filename), sizeof(en->name));
                                  ^
    216. 
    217.     en->duration = duration;
