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

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

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

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

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

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

libavutil/pixdesc.c:1676:1: start of procedure av_pix_fmt_desc_next()
  1674. }
  1675. 
  1676. const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
        ^
  1677. {
  1678.     if (!prev)

libavutil/pixdesc.c:1678:10: Taking true branch
  1676. const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
  1677. {
  1678.     if (!prev)
                 ^
  1679.         return &av_pix_fmt_descriptors[0];
  1680.     if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)

libavutil/pixdesc.c:1679:9: 
  1677. {
  1678.     if (!prev)
  1679.         return &av_pix_fmt_descriptors[0];
                ^
  1680.     if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)
  1681.         return prev + 1;

libavutil/pixdesc.c:1683:1: return from a call to av_pix_fmt_desc_next
  1681.         return prev + 1;
  1682.     return NULL;
  1683. }
        ^
  1684. 
  1685. enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)

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

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

libavutil/pixdesc.c:1685:1: start of procedure av_pix_fmt_desc_get_id()
  1683. }
  1684. 
  1685. enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
        ^
  1686. {
  1687.     if (desc < av_pix_fmt_descriptors ||

libavutil/pixdesc.c:1687:9: Taking false branch
  1685. enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
  1686. {
  1687.     if (desc < av_pix_fmt_descriptors ||
                ^
  1688.         desc >= av_pix_fmt_descriptors + FF_ARRAY_ELEMS(av_pix_fmt_descriptors))
  1689.         return AV_PIX_FMT_NONE;

libavutil/pixdesc.c:1688:9: Taking false branch
  1686. {
  1687.     if (desc < av_pix_fmt_descriptors ||
  1688.         desc >= av_pix_fmt_descriptors + FF_ARRAY_ELEMS(av_pix_fmt_descriptors))
                ^
  1689.         return AV_PIX_FMT_NONE;
  1690. 

libavutil/pixdesc.c:1691:5: 
  1689.         return AV_PIX_FMT_NONE;
  1690. 
  1691.     return desc - av_pix_fmt_descriptors;
            ^
  1692. }
  1693. FF_ENABLE_DEPRECATION_WARNINGS

libavutil/pixdesc.c:1692:1: return from a call to av_pix_fmt_desc_get_id
  1690. 
  1691.     return desc - av_pix_fmt_descriptors;
  1692. }
        ^
  1693. FF_ENABLE_DEPRECATION_WARNINGS
  1694. 

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

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

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

libavutil/pixdesc.c:1676:1: start of procedure av_pix_fmt_desc_next()
  1674. }
  1675. 
  1676. const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
        ^
  1677. {
  1678.     if (!prev)

libavutil/pixdesc.c:1678:10: Taking false branch
  1676. const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
  1677. {
  1678.     if (!prev)
                 ^
  1679.         return &av_pix_fmt_descriptors[0];
  1680.     if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)

libavutil/pixdesc.c:1680:9: Taking true branch
  1678.     if (!prev)
  1679.         return &av_pix_fmt_descriptors[0];
  1680.     if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)
                ^
  1681.         return prev + 1;
  1682.     return NULL;

libavutil/pixdesc.c:1681:9: 
  1679.         return &av_pix_fmt_descriptors[0];
  1680.     if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)
  1681.         return prev + 1;
                ^
  1682.     return NULL;
  1683. }

libavutil/pixdesc.c:1683:1: return from a call to av_pix_fmt_desc_next
  1681.         return prev + 1;
  1682.     return NULL;
  1683. }
        ^
  1684. 
  1685. enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)

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

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

libavutil/pixdesc.c:1685:1: start of procedure av_pix_fmt_desc_get_id()
  1683. }
  1684. 
  1685. enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
        ^
  1686. {
  1687.     if (desc < av_pix_fmt_descriptors ||

libavutil/pixdesc.c:1687:9: Taking false branch
  1685. enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
  1686. {
  1687.     if (desc < av_pix_fmt_descriptors ||
                ^
  1688.         desc >= av_pix_fmt_descriptors + FF_ARRAY_ELEMS(av_pix_fmt_descriptors))
  1689.         return AV_PIX_FMT_NONE;

libavutil/pixdesc.c:1688:9: Taking false branch
  1686. {
  1687.     if (desc < av_pix_fmt_descriptors ||
  1688.         desc >= av_pix_fmt_descriptors + FF_ARRAY_ELEMS(av_pix_fmt_descriptors))
                ^
  1689.         return AV_PIX_FMT_NONE;
  1690. 

libavutil/pixdesc.c:1691:5: 
  1689.         return AV_PIX_FMT_NONE;
  1690. 
  1691.     return desc - av_pix_fmt_descriptors;
            ^
  1692. }
  1693. FF_ENABLE_DEPRECATION_WARNINGS

libavutil/pixdesc.c:1692:1: return from a call to av_pix_fmt_desc_get_id
  1690. 
  1691.     return desc - av_pix_fmt_descriptors;
  1692. }
        ^
  1693. FF_ENABLE_DEPRECATION_WARNINGS
  1694. 

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

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

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

libavutil/pixdesc.c:1676:1: start of procedure av_pix_fmt_desc_next()
  1674. }
  1675. 
  1676. const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
        ^
  1677. {
  1678.     if (!prev)

libavutil/pixdesc.c:1678:10: Taking false branch
  1676. const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
  1677. {
  1678.     if (!prev)
                 ^
  1679.         return &av_pix_fmt_descriptors[0];
  1680.     if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)

libavutil/pixdesc.c:1680:9: Taking true branch
  1678.     if (!prev)
  1679.         return &av_pix_fmt_descriptors[0];
  1680.     if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)
                ^
  1681.         return prev + 1;
  1682.     return NULL;

libavutil/pixdesc.c:1681:9: 
  1679.         return &av_pix_fmt_descriptors[0];
  1680.     if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)
  1681.         return prev + 1;
                ^
  1682.     return NULL;
  1683. }

libavutil/pixdesc.c:1683:1: return from a call to av_pix_fmt_desc_next
  1681.         return prev + 1;
  1682.     return NULL;
  1683. }
        ^
  1684. 
  1685. enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)

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

libavfilter/vf_scale.c:134:9: 
132.             }
133.         }
134.         ff_formats_ref(formats, &ctx->inputs[0]->out_formats);
             ^
135.     }
136.     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. 
