libavfilter/vf_scale.c:135: error: Null Dereference
  pointer `formats` last assigned on line 125 could be null and is dereferenced by call to `ff_formats_ref()` at line 135, column 9.

libavfilter/vf_scale.c:117:1: start of procedure query_formats()
115. }
116. 
117. static int query_formats(AVFilterContext *ctx)
     ^
118. {
119.     AVFilterFormats *formats;

libavfilter/vf_scale.c:123:9: Taking true branch
121.     int ret;
122. 
123.     if (ctx->inputs[0]) {
             ^
124.         const AVPixFmtDescriptor *desc = NULL;
125.         formats = NULL;

libavfilter/vf_scale.c:124:9: 
122. 
123.     if (ctx->inputs[0]) {
124.         const AVPixFmtDescriptor *desc = NULL;
             ^
125.         formats = NULL;
126.         while ((desc = av_pix_fmt_desc_next(desc))) {

libavfilter/vf_scale.c:125:9: 
123.     if (ctx->inputs[0]) {
124.         const AVPixFmtDescriptor *desc = NULL;
125.         formats = NULL;
             ^
126.         while ((desc = av_pix_fmt_desc_next(desc))) {
127.             pix_fmt = av_pix_fmt_desc_get_id(desc);

libavfilter/vf_scale.c:126:17: 
124.         const AVPixFmtDescriptor *desc = NULL;
125.         formats = NULL;
126.         while ((desc = av_pix_fmt_desc_next(desc))) {
                     ^
127.             pix_fmt = av_pix_fmt_desc_get_id(desc);
128.             if ((sws_isSupportedInput(pix_fmt) ||

libavutil/pixdesc.c:1686:1: start of procedure av_pix_fmt_desc_next()
  1684. }
  1685. 
  1686. const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
        ^
  1687. {
  1688.     if (!prev)

libavutil/pixdesc.c:1688:10: Taking true branch
  1686. const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
  1687. {
  1688.     if (!prev)
                 ^
  1689.         return &av_pix_fmt_descriptors[0];
  1690.     if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)

libavutil/pixdesc.c:1689:9: 
  1687. {
  1688.     if (!prev)
  1689.         return &av_pix_fmt_descriptors[0];
                ^
  1690.     if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)
  1691.         return prev + 1;

libavutil/pixdesc.c:1693:1: return from a call to av_pix_fmt_desc_next
  1691.         return prev + 1;
  1692.     return NULL;
  1693. }
        ^
  1694. 
  1695. enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)

libavfilter/vf_scale.c:126:17: Loop condition is true. Entering loop body
124.         const AVPixFmtDescriptor *desc = NULL;
125.         formats = NULL;
126.         while ((desc = av_pix_fmt_desc_next(desc))) {
                     ^
127.             pix_fmt = av_pix_fmt_desc_get_id(desc);
128.             if ((sws_isSupportedInput(pix_fmt) ||

libavfilter/vf_scale.c:127:13: 
125.         formats = NULL;
126.         while ((desc = av_pix_fmt_desc_next(desc))) {
127.             pix_fmt = av_pix_fmt_desc_get_id(desc);
                 ^
128.             if ((sws_isSupportedInput(pix_fmt) ||
129.                  sws_isSupportedEndiannessConversion(pix_fmt))

libavutil/pixdesc.c:1695:1: start of procedure av_pix_fmt_desc_get_id()
  1693. }
  1694. 
  1695. enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
        ^
  1696. {
  1697.     if (desc < av_pix_fmt_descriptors ||

libavutil/pixdesc.c:1697:9: Taking false branch
  1695. enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
  1696. {
  1697.     if (desc < av_pix_fmt_descriptors ||
                ^
  1698.         desc >= av_pix_fmt_descriptors + FF_ARRAY_ELEMS(av_pix_fmt_descriptors))
  1699.         return AV_PIX_FMT_NONE;

libavutil/pixdesc.c:1698:9: Taking false branch
  1696. {
  1697.     if (desc < av_pix_fmt_descriptors ||
  1698.         desc >= av_pix_fmt_descriptors + FF_ARRAY_ELEMS(av_pix_fmt_descriptors))
                ^
  1699.         return AV_PIX_FMT_NONE;
  1700. 

libavutil/pixdesc.c:1701:5: 
  1699.         return AV_PIX_FMT_NONE;
  1700. 
  1701.     return desc - av_pix_fmt_descriptors;
            ^
  1702. }
  1703. FF_ENABLE_DEPRECATION_WARNINGS

libavutil/pixdesc.c:1702:1: return from a call to av_pix_fmt_desc_get_id
  1700. 
  1701.     return desc - av_pix_fmt_descriptors;
  1702. }
        ^
  1703. FF_ENABLE_DEPRECATION_WARNINGS
  1704. 

libavfilter/vf_scale.c:128:18: 
126.         while ((desc = av_pix_fmt_desc_next(desc))) {
127.             pix_fmt = av_pix_fmt_desc_get_id(desc);
128.             if ((sws_isSupportedInput(pix_fmt) ||
                      ^
129.                  sws_isSupportedEndiannessConversion(pix_fmt))
130.                 && (ret = ff_add_format(&formats, pix_fmt)) < 0) {

libswscale/utils.c:190:1: start of procedure sws_isSupportedInput()
  188. };
  189. 
  190. int sws_isSupportedInput(enum AVPixelFormat pix_fmt)
       ^
  191. {
  192.     return (unsigned)pix_fmt < AV_PIX_FMT_NB ?

libswscale/utils.c:192:12: Condition is true
  190. int sws_isSupportedInput(enum AVPixelFormat pix_fmt)
  191. {
  192.     return (unsigned)pix_fmt < AV_PIX_FMT_NB ?
                  ^
  193.            format_entries[pix_fmt].is_supported_in : 0;
  194. }

libswscale/utils.c:192:5: 
  190. int sws_isSupportedInput(enum AVPixelFormat pix_fmt)
  191. {
  192.     return (unsigned)pix_fmt < AV_PIX_FMT_NB ?
           ^
  193.            format_entries[pix_fmt].is_supported_in : 0;
  194. }

libswscale/utils.c:194:1: return from a call to sws_isSupportedInput
  192.     return (unsigned)pix_fmt < AV_PIX_FMT_NB ?
  193.            format_entries[pix_fmt].is_supported_in : 0;
  194. }
       ^
  195. 
  196. int sws_isSupportedOutput(enum AVPixelFormat pix_fmt)

libavfilter/vf_scale.c:128:18: Taking false branch
126.         while ((desc = av_pix_fmt_desc_next(desc))) {
127.             pix_fmt = av_pix_fmt_desc_get_id(desc);
128.             if ((sws_isSupportedInput(pix_fmt) ||
                      ^
129.                  sws_isSupportedEndiannessConversion(pix_fmt))
130.                 && (ret = ff_add_format(&formats, pix_fmt)) < 0) {

libavfilter/vf_scale.c:129:18: 
127.             pix_fmt = av_pix_fmt_desc_get_id(desc);
128.             if ((sws_isSupportedInput(pix_fmt) ||
129.                  sws_isSupportedEndiannessConversion(pix_fmt))
                      ^
130.                 && (ret = ff_add_format(&formats, pix_fmt)) < 0) {
131.                 ff_formats_unref(&formats);

libswscale/utils.c:202:1: start of procedure sws_isSupportedEndiannessConversion()
  200. }
  201. 
  202. int sws_isSupportedEndiannessConversion(enum AVPixelFormat pix_fmt)
       ^
  203. {
  204.     return (unsigned)pix_fmt < AV_PIX_FMT_NB ?

libswscale/utils.c:204:12: Condition is true
  202. int sws_isSupportedEndiannessConversion(enum AVPixelFormat pix_fmt)
  203. {
  204.     return (unsigned)pix_fmt < AV_PIX_FMT_NB ?
                  ^
  205.            format_entries[pix_fmt].is_supported_endianness : 0;
  206. }

libswscale/utils.c:204:5: 
  202. int sws_isSupportedEndiannessConversion(enum AVPixelFormat pix_fmt)
  203. {
  204.     return (unsigned)pix_fmt < AV_PIX_FMT_NB ?
           ^
  205.            format_entries[pix_fmt].is_supported_endianness : 0;
  206. }

libswscale/utils.c:206:1: return from a call to sws_isSupportedEndiannessConversion
  204.     return (unsigned)pix_fmt < AV_PIX_FMT_NB ?
  205.            format_entries[pix_fmt].is_supported_endianness : 0;
  206. }
       ^
  207. 
  208. const char *sws_format_name(enum AVPixelFormat format)

libavfilter/vf_scale.c:129:18: Taking false branch
127.             pix_fmt = av_pix_fmt_desc_get_id(desc);
128.             if ((sws_isSupportedInput(pix_fmt) ||
129.                  sws_isSupportedEndiannessConversion(pix_fmt))
                      ^
130.                 && (ret = ff_add_format(&formats, pix_fmt)) < 0) {
131.                 ff_formats_unref(&formats);

libavfilter/vf_scale.c:126:17: 
124.         const AVPixFmtDescriptor *desc = NULL;
125.         formats = NULL;
126.         while ((desc = av_pix_fmt_desc_next(desc))) {
                     ^
127.             pix_fmt = av_pix_fmt_desc_get_id(desc);
128.             if ((sws_isSupportedInput(pix_fmt) ||

libavutil/pixdesc.c:1686:1: start of procedure av_pix_fmt_desc_next()
  1684. }
  1685. 
  1686. const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
        ^
  1687. {
  1688.     if (!prev)

libavutil/pixdesc.c:1688:10: Taking false branch
  1686. const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
  1687. {
  1688.     if (!prev)
                 ^
  1689.         return &av_pix_fmt_descriptors[0];
  1690.     if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)

libavutil/pixdesc.c:1690:9: Taking true branch
  1688.     if (!prev)
  1689.         return &av_pix_fmt_descriptors[0];
  1690.     if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)
                ^
  1691.         return prev + 1;
  1692.     return NULL;

libavutil/pixdesc.c:1691:9: 
  1689.         return &av_pix_fmt_descriptors[0];
  1690.     if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)
  1691.         return prev + 1;
                ^
  1692.     return NULL;
  1693. }

libavutil/pixdesc.c:1693:1: return from a call to av_pix_fmt_desc_next
  1691.         return prev + 1;
  1692.     return NULL;
  1693. }
        ^
  1694. 
  1695. enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)

libavfilter/vf_scale.c:126:17: Loop condition is true. Entering loop body
124.         const AVPixFmtDescriptor *desc = NULL;
125.         formats = NULL;
126.         while ((desc = av_pix_fmt_desc_next(desc))) {
                     ^
127.             pix_fmt = av_pix_fmt_desc_get_id(desc);
128.             if ((sws_isSupportedInput(pix_fmt) ||

libavfilter/vf_scale.c:127:13: 
125.         formats = NULL;
126.         while ((desc = av_pix_fmt_desc_next(desc))) {
127.             pix_fmt = av_pix_fmt_desc_get_id(desc);
                 ^
128.             if ((sws_isSupportedInput(pix_fmt) ||
129.                  sws_isSupportedEndiannessConversion(pix_fmt))

libavutil/pixdesc.c:1695:1: start of procedure av_pix_fmt_desc_get_id()
  1693. }
  1694. 
  1695. enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
        ^
  1696. {
  1697.     if (desc < av_pix_fmt_descriptors ||

libavutil/pixdesc.c:1697:9: Taking false branch
  1695. enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
  1696. {
  1697.     if (desc < av_pix_fmt_descriptors ||
                ^
  1698.         desc >= av_pix_fmt_descriptors + FF_ARRAY_ELEMS(av_pix_fmt_descriptors))
  1699.         return AV_PIX_FMT_NONE;

libavutil/pixdesc.c:1698:9: Taking false branch
  1696. {
  1697.     if (desc < av_pix_fmt_descriptors ||
  1698.         desc >= av_pix_fmt_descriptors + FF_ARRAY_ELEMS(av_pix_fmt_descriptors))
                ^
  1699.         return AV_PIX_FMT_NONE;
  1700. 

libavutil/pixdesc.c:1701:5: 
  1699.         return AV_PIX_FMT_NONE;
  1700. 
  1701.     return desc - av_pix_fmt_descriptors;
            ^
  1702. }
  1703. FF_ENABLE_DEPRECATION_WARNINGS

libavutil/pixdesc.c:1702:1: return from a call to av_pix_fmt_desc_get_id
  1700. 
  1701.     return desc - av_pix_fmt_descriptors;
  1702. }
        ^
  1703. FF_ENABLE_DEPRECATION_WARNINGS
  1704. 

libavfilter/vf_scale.c:128:18: 
126.         while ((desc = av_pix_fmt_desc_next(desc))) {
127.             pix_fmt = av_pix_fmt_desc_get_id(desc);
128.             if ((sws_isSupportedInput(pix_fmt) ||
                      ^
129.                  sws_isSupportedEndiannessConversion(pix_fmt))
130.                 && (ret = ff_add_format(&formats, pix_fmt)) < 0) {

libswscale/utils.c:190:1: start of procedure sws_isSupportedInput()
  188. };
  189. 
  190. int sws_isSupportedInput(enum AVPixelFormat pix_fmt)
       ^
  191. {
  192.     return (unsigned)pix_fmt < AV_PIX_FMT_NB ?

libswscale/utils.c:192:12: Condition is true
  190. int sws_isSupportedInput(enum AVPixelFormat pix_fmt)
  191. {
  192.     return (unsigned)pix_fmt < AV_PIX_FMT_NB ?
                  ^
  193.            format_entries[pix_fmt].is_supported_in : 0;
  194. }

libswscale/utils.c:192:5: 
  190. int sws_isSupportedInput(enum AVPixelFormat pix_fmt)
  191. {
  192.     return (unsigned)pix_fmt < AV_PIX_FMT_NB ?
           ^
  193.            format_entries[pix_fmt].is_supported_in : 0;
  194. }

libswscale/utils.c:194:1: return from a call to sws_isSupportedInput
  192.     return (unsigned)pix_fmt < AV_PIX_FMT_NB ?
  193.            format_entries[pix_fmt].is_supported_in : 0;
  194. }
       ^
  195. 
  196. int sws_isSupportedOutput(enum AVPixelFormat pix_fmt)

libavfilter/vf_scale.c:128:18: Taking false branch
126.         while ((desc = av_pix_fmt_desc_next(desc))) {
127.             pix_fmt = av_pix_fmt_desc_get_id(desc);
128.             if ((sws_isSupportedInput(pix_fmt) ||
                      ^
129.                  sws_isSupportedEndiannessConversion(pix_fmt))
130.                 && (ret = ff_add_format(&formats, pix_fmt)) < 0) {

libavfilter/vf_scale.c:129:18: 
127.             pix_fmt = av_pix_fmt_desc_get_id(desc);
128.             if ((sws_isSupportedInput(pix_fmt) ||
129.                  sws_isSupportedEndiannessConversion(pix_fmt))
                      ^
130.                 && (ret = ff_add_format(&formats, pix_fmt)) < 0) {
131.                 ff_formats_unref(&formats);

libswscale/utils.c:202:1: start of procedure sws_isSupportedEndiannessConversion()
  200. }
  201. 
  202. int sws_isSupportedEndiannessConversion(enum AVPixelFormat pix_fmt)
       ^
  203. {
  204.     return (unsigned)pix_fmt < AV_PIX_FMT_NB ?

libswscale/utils.c:204:12: Condition is true
  202. int sws_isSupportedEndiannessConversion(enum AVPixelFormat pix_fmt)
  203. {
  204.     return (unsigned)pix_fmt < AV_PIX_FMT_NB ?
                  ^
  205.            format_entries[pix_fmt].is_supported_endianness : 0;
  206. }

libswscale/utils.c:204:5: 
  202. int sws_isSupportedEndiannessConversion(enum AVPixelFormat pix_fmt)
  203. {
  204.     return (unsigned)pix_fmt < AV_PIX_FMT_NB ?
           ^
  205.            format_entries[pix_fmt].is_supported_endianness : 0;
  206. }

libswscale/utils.c:206:1: return from a call to sws_isSupportedEndiannessConversion
  204.     return (unsigned)pix_fmt < AV_PIX_FMT_NB ?
  205.            format_entries[pix_fmt].is_supported_endianness : 0;
  206. }
       ^
  207. 
  208. const char *sws_format_name(enum AVPixelFormat format)

libavfilter/vf_scale.c:129:18: Taking false branch
127.             pix_fmt = av_pix_fmt_desc_get_id(desc);
128.             if ((sws_isSupportedInput(pix_fmt) ||
129.                  sws_isSupportedEndiannessConversion(pix_fmt))
                      ^
130.                 && (ret = ff_add_format(&formats, pix_fmt)) < 0) {
131.                 ff_formats_unref(&formats);

libavfilter/vf_scale.c:126:17: 
124.         const AVPixFmtDescriptor *desc = NULL;
125.         formats = NULL;
126.         while ((desc = av_pix_fmt_desc_next(desc))) {
                     ^
127.             pix_fmt = av_pix_fmt_desc_get_id(desc);
128.             if ((sws_isSupportedInput(pix_fmt) ||

libavutil/pixdesc.c:1686:1: start of procedure av_pix_fmt_desc_next()
  1684. }
  1685. 
  1686. const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
        ^
  1687. {
  1688.     if (!prev)

libavutil/pixdesc.c:1688:10: Taking false branch
  1686. const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
  1687. {
  1688.     if (!prev)
                 ^
  1689.         return &av_pix_fmt_descriptors[0];
  1690.     if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)

libavutil/pixdesc.c:1690:9: Taking true branch
  1688.     if (!prev)
  1689.         return &av_pix_fmt_descriptors[0];
  1690.     if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)
                ^
  1691.         return prev + 1;
  1692.     return NULL;

libavutil/pixdesc.c:1691:9: 
  1689.         return &av_pix_fmt_descriptors[0];
  1690.     if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)
  1691.         return prev + 1;
                ^
  1692.     return NULL;
  1693. }

libavutil/pixdesc.c:1693:1: return from a call to av_pix_fmt_desc_next
  1691.         return prev + 1;
  1692.     return NULL;
  1693. }
        ^
  1694. 
  1695. enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)

libavfilter/vf_scale.c:126:17: Loop condition is false. Leaving loop
124.         const AVPixFmtDescriptor *desc = NULL;
125.         formats = NULL;
126.         while ((desc = av_pix_fmt_desc_next(desc))) {
                     ^
127.             pix_fmt = av_pix_fmt_desc_get_id(desc);
128.             if ((sws_isSupportedInput(pix_fmt) ||

libavfilter/vf_scale.c:135:9: 
133.             }
134.         }
135.         ff_formats_ref(formats, &ctx->inputs[0]->out_formats);
             ^
136.     }
137.     if (ctx->outputs[0]) {

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

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