libavfilter/vf_hwdownload.c:58: error: Null Dereference
  pointer `infmts` last assigned on line 40 could be null and is dereferenced by call to `ff_formats_ref()` at line 58, column 5.

libavfilter/vf_hwdownload.c:38:1: start of procedure hwdownload_query_formats()
36. } HWDownloadContext;
37. 
38. static int hwdownload_query_formats(AVFilterContext *avctx)
    ^
39. {
40.     AVFilterFormats  *infmts = NULL;

libavfilter/vf_hwdownload.c:40:5: 
38. static int hwdownload_query_formats(AVFilterContext *avctx)
39. {
40.     AVFilterFormats  *infmts = NULL;
        ^
41.     AVFilterFormats *outfmts = NULL;
42.     const AVPixFmtDescriptor *desc;

libavfilter/vf_hwdownload.c:41:5: 
39. {
40.     AVFilterFormats  *infmts = NULL;
41.     AVFilterFormats *outfmts = NULL;
        ^
42.     const AVPixFmtDescriptor *desc;
43.     int err;

libavfilter/vf_hwdownload.c:45:10: 
43.     int err;
44. 
45.     for (desc = av_pix_fmt_desc_next(NULL); desc;
             ^
46.          desc = av_pix_fmt_desc_next(desc)) {
47.         if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL)

libavutil/pixdesc.c:1710:1: start of procedure av_pix_fmt_desc_next()
  1708. }
  1709. 
  1710. const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
        ^
  1711. {
  1712.     if (!prev)

libavutil/pixdesc.c:1712:10: Taking true branch
  1710. const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
  1711. {
  1712.     if (!prev)
                 ^
  1713.         return &av_pix_fmt_descriptors[0];
  1714.     if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)

libavutil/pixdesc.c:1713:9: 
  1711. {
  1712.     if (!prev)
  1713.         return &av_pix_fmt_descriptors[0];
                ^
  1714.     if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)
  1715.         return prev + 1;

libavutil/pixdesc.c:1717:1: return from a call to av_pix_fmt_desc_next
  1715.         return prev + 1;
  1716.     return NULL;
  1717. }
        ^
  1718. 
  1719. enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)

libavfilter/vf_hwdownload.c:45:45: Loop condition is false. Leaving loop
43.     int err;
44. 
45.     for (desc = av_pix_fmt_desc_next(NULL); desc;
                                                ^
46.          desc = av_pix_fmt_desc_next(desc)) {
47.         if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL)

libavfilter/vf_hwdownload.c:58:5: 
56.     }
57. 
58.     ff_formats_ref(infmts,  &avctx->inputs[0]->out_formats);
        ^
59.     ff_formats_ref(outfmts, &avctx->outputs[0]->in_formats);
60.     return 0;

libavfilter/formats.c:276:1: start of procedure ff_formats_ref()
  274. }
  275. 
  276. void ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
       ^
  277. {
  278.     FORMATS_REF(f, ref);

libavfilter/formats.c:278:5: 
  276. void ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
  277. {
  278.     FORMATS_REF(f, ref);
           ^
  279. }
  280. 

static int hwdownload_query_formats(AVFilterContext *avctx)
{
    AVFilterFormats  *infmts = NULL;
    AVFilterFormats *outfmts = NULL;
    const AVPixFmtDescriptor *desc;
    int err;
    for (desc = av_pix_fmt_desc_next(NULL); desc;
         desc = av_pix_fmt_desc_next(desc)) {
        if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
            err = ff_add_format(&infmts,  av_pix_fmt_desc_get_id(desc));
        else
            err = ff_add_format(&outfmts, av_pix_fmt_desc_get_id(desc));
        if (err) {
            ff_formats_unref(&infmts);
            ff_formats_unref(&outfmts);
            return err;
        }
    }
    ff_formats_ref(infmts,  &avctx->inputs[0]->out_formats);
    ff_formats_ref(outfmts, &avctx->outputs[0]->in_formats);
    return 0;
}
['static int hwdownload_query_formats(AVFilterContext *avctx)\n{\n    AVFilterFormats  *infmts = NULL;\n    AVFilterFormats *outfmts = NULL;\n    const AVPixFmtDescriptor *desc;\n    int err;\n    for (desc = av_pix_fmt_desc_next(NULL); desc;\n         desc = av_pix_fmt_desc_next(desc)) {\n        if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL)\n            err = ff_add_format(&infmts,  av_pix_fmt_desc_get_id(desc));\n        else\n            err = ff_add_format(&outfmts, av_pix_fmt_desc_get_id(desc));\n        if (err) {\n            ff_formats_unref(&infmts);\n            ff_formats_unref(&outfmts);\n            return err;\n        }\n    }\n    ff_formats_ref(infmts,  &avctx->inputs[0]->out_formats);\n    ff_formats_ref(outfmts, &avctx->outputs[0]->in_formats);\n    return 0;\n}', 'const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)\n{\n    if (!prev)\n        return &av_pix_fmt_descriptors[0];\n    if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)\n        return prev + 1;\n    return NULL;\n}', 'void ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)\n{\n    FORMATS_REF(f, ref);\n}']