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

libavformat/hlsenc.c:493:1: invalidation part of the trace starts here
491. }
492. 
493. static int hls_write_trailer(struct AVFormatContext *s)
     ^
494. {
495.     HLSContext *hls = s->priv_data;

libavformat/hlsenc.c:493:1: parameter `s` of hls_write_trailer
  491. }
  492. 
  493. static int hls_write_trailer(struct AVFormatContext *s)
       ^
  494. {
  495.     HLSContext *hls = s->priv_data;

libavformat/hlsenc.c:495:5: assigned
  493. static int hls_write_trailer(struct AVFormatContext *s)
  494. {
  495.     HLSContext *hls = s->priv_data;
           ^
  496.     AVFormatContext *oc = hls->avf;
  497. 

libavformat/hlsenc.c:496:5: assigned
  494. {
  495.     HLSContext *hls = s->priv_data;
  496.     AVFormatContext *oc = hls->avf;
           ^
  497. 
  498.     av_write_trailer(oc);

libavformat/hlsenc.c:500:5: when calling `avformat_free_context` here
  498.     av_write_trailer(oc);
  499.     ff_format_io_close(s, &oc->pb);
  500.     avformat_free_context(oc);
           ^
  501.     av_free(hls->basename);
  502.     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:493:1: use-after-lifetime part of the trace starts here
491. }
492. 
493. static int hls_write_trailer(struct AVFormatContext *s)
     ^
494. {
495.     HLSContext *hls = s->priv_data;

libavformat/hlsenc.c:493:1: parameter `s` of hls_write_trailer
  491. }
  492. 
  493. static int hls_write_trailer(struct AVFormatContext *s)
       ^
  494. {
  495.     HLSContext *hls = s->priv_data;

libavformat/hlsenc.c:495:5: assigned
  493. static int hls_write_trailer(struct AVFormatContext *s)
  494. {
  495.     HLSContext *hls = s->priv_data;
           ^
  496.     AVFormatContext *oc = hls->avf;
  497. 

libavformat/hlsenc.c:502:5: when calling `append_entry` here
  500.     avformat_free_context(oc);
  501.     av_free(hls->basename);
  502.     append_entry(hls, hls->duration);
           ^
  503.     hls_window(s, 1);
  504. 

libavformat/hlsenc.c:203:1: parameter `hls` of append_entry
    201. }
    202. 
    203. static int append_entry(HLSContext *hls, int64_t duration)
         ^
    204. {
    205.     ListEntry *en = av_malloc(sizeof(*en));

libavformat/hlsenc.c:210:26: invalid access occurs here
    208.         return AVERROR(ENOMEM);
    209. 
    210.     av_strlcpy(en->name, av_basename(hls->avf->filename), sizeof(en->name));
                                  ^
    211. 
    212.     en->duration = duration;
