libavfilter/formats.c:224: error: Use After Free
  call to `ff_add_format()` eventually accesses memory that was invalidated by call to `free()` on line 224 indirectly during the call to `ff_add_format()`.

libavfilter/formats.c:213:5: invalidation part of the trace starts here
211. AVFilterFormats *ff_all_formats(enum AVMediaType type)
212. {
213.     AVFilterFormats *ret = NULL;
         ^
214. 
215.     if (type == AVMEDIA_TYPE_VIDEO) {

libavfilter/formats.c:213:5: variable `ret` declared here
  211. AVFilterFormats *ff_all_formats(enum AVMediaType type)
  212. {
  213.     AVFilterFormats *ret = NULL;
           ^
  214. 
  215.     if (type == AVMEDIA_TYPE_VIDEO) {

libavfilter/formats.c:224:13: when calling `ff_add_format` here
  222.         enum AVSampleFormat fmt = 0;
  223.         while (av_get_sample_fmt_name(fmt)) {
  224.             ff_add_format(&ret, fmt);
                   ^
  225.             fmt++;
  226.         }

libavfilter/formats.c:201:1: parameter `avff` of ff_add_format
    199. } while (0)
    200. 
    201. int ff_add_format(AVFilterFormats **avff, int fmt)
         ^
    202. {
    203.     ADD_FORMAT(avff, fmt, int, formats, nb_formats);

libavfilter/formats.c:203:5: when calling `av_freep` here
    201. int ff_add_format(AVFilterFormats **avff, int fmt)
    202. {
    203.     ADD_FORMAT(avff, fmt, int, formats, nb_formats);
             ^
    204. }
    205. 

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/formats.c:213:5: use-after-lifetime part of the trace starts here
211. AVFilterFormats *ff_all_formats(enum AVMediaType type)
212. {
213.     AVFilterFormats *ret = NULL;
         ^
214. 
215.     if (type == AVMEDIA_TYPE_VIDEO) {

libavfilter/formats.c:213:5: variable `ret` declared here
  211. AVFilterFormats *ff_all_formats(enum AVMediaType type)
  212. {
  213.     AVFilterFormats *ret = NULL;
           ^
  214. 
  215.     if (type == AVMEDIA_TYPE_VIDEO) {

libavfilter/formats.c:224:13: when calling `ff_add_format` here
  222.         enum AVSampleFormat fmt = 0;
  223.         while (av_get_sample_fmt_name(fmt)) {
  224.             ff_add_format(&ret, fmt);
                   ^
  225.             fmt++;
  226.         }

libavfilter/formats.c:201:1: parameter `avff` of ff_add_format
    199. } while (0)
    200. 
    201. int ff_add_format(AVFilterFormats **avff, int fmt)
         ^
    202. {
    203.     ADD_FORMAT(avff, fmt, int, formats, nb_formats);

libavfilter/formats.c:203:5: invalid access occurs here
    201. int ff_add_format(AVFilterFormats **avff, int fmt)
    202. {
    203.     ADD_FORMAT(avff, fmt, int, formats, nb_formats);
             ^
    204. }
    205. 

int ff_add_format(AVFilterFormats **avff, int fmt)
{
    ADD_FORMAT(avff, fmt, int, formats, nb_formats);
}
['AVFilterFormats *ff_all_formats(enum AVMediaType type)\n{\n    AVFilterFormats *ret = NULL;\n    if (type == AVMEDIA_TYPE_VIDEO) {\n        const AVPixFmtDescriptor *desc = NULL;\n        while ((desc = av_pix_fmt_desc_next(desc))) {\n            if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL))\n                ff_add_format(&ret, av_pix_fmt_desc_get_id(desc));\n        }\n    } else if (type == AVMEDIA_TYPE_AUDIO) {\n        enum AVSampleFormat fmt = 0;\n        while (av_get_sample_fmt_name(fmt)) {\n            ff_add_format(&ret, fmt);\n            fmt++;\n        }\n    }\n    return ret;\n}', 'int ff_add_format(AVFilterFormats **avff, int fmt)\n{\n    ADD_FORMAT(avff, fmt, int, formats, nb_formats);\n}', 'void av_freep(void *arg)\n{\n    void **ptr = (void **)arg;\n    av_free(*ptr);\n    *ptr = NULL;\n}', 'void av_free(void *ptr)\n{\n#if CONFIG_MEMALIGN_HACK\n    if (ptr)\n        free((char *)ptr - ((char *)ptr)[-1]);\n#elif HAVE_ALIGNED_MALLOC\n    _aligned_free(ptr);\n#else\n    free(ptr);\n#endif\n}']