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:1692:1: start of procedure av_pix_fmt_desc_next()
  1690. }
  1691. 
  1692. const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
        ^
  1693. {
  1694.     if (!prev)

libavutil/pixdesc.c:1694:10: Taking true branch
  1692. const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
  1693. {
  1694.     if (!prev)
                 ^
  1695.         return &av_pix_fmt_descriptors[0];
  1696.     if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)

libavutil/pixdesc.c:1695:9: 
  1693. {
  1694.     if (!prev)
  1695.         return &av_pix_fmt_descriptors[0];
                ^
  1696.     if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)
  1697.         return prev + 1;

libavutil/pixdesc.c:1699:1: return from a call to av_pix_fmt_desc_next
  1697.         return prev + 1;
  1698.     return NULL;
  1699. }
        ^
  1700. 
  1701. 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:1701:1: start of procedure av_pix_fmt_desc_get_id()
  1699. }
  1700. 
  1701. enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
        ^
  1702. {
  1703.     if (desc < av_pix_fmt_descriptors ||

libavutil/pixdesc.c:1703:9: Taking false branch
  1701. enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
  1702. {
  1703.     if (desc < av_pix_fmt_descriptors ||
                ^
  1704.         desc >= av_pix_fmt_descriptors + FF_ARRAY_ELEMS(av_pix_fmt_descriptors))
  1705.         return AV_PIX_FMT_NONE;

libavutil/pixdesc.c:1704:9: Taking false branch
  1702. {
  1703.     if (desc < av_pix_fmt_descriptors ||
  1704.         desc >= av_pix_fmt_descriptors + FF_ARRAY_ELEMS(av_pix_fmt_descriptors))
                ^
  1705.         return AV_PIX_FMT_NONE;
  1706. 

libavutil/pixdesc.c:1707:5: 
  1705.         return AV_PIX_FMT_NONE;
  1706. 
  1707.     return desc - av_pix_fmt_descriptors;
            ^
  1708. }
  1709. 

libavutil/pixdesc.c:1708:1: return from a call to av_pix_fmt_desc_get_id
  1706. 
  1707.     return desc - av_pix_fmt_descriptors;
  1708. }
        ^
  1709. 
  1710. int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt,

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:1692:1: start of procedure av_pix_fmt_desc_next()
  1690. }
  1691. 
  1692. const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
        ^
  1693. {
  1694.     if (!prev)

libavutil/pixdesc.c:1694:10: Taking false branch
  1692. const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
  1693. {
  1694.     if (!prev)
                 ^
  1695.         return &av_pix_fmt_descriptors[0];
  1696.     if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)

libavutil/pixdesc.c:1696:9: Taking true branch
  1694.     if (!prev)
  1695.         return &av_pix_fmt_descriptors[0];
  1696.     if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)
                ^
  1697.         return prev + 1;
  1698.     return NULL;

libavutil/pixdesc.c:1697:9: 
  1695.         return &av_pix_fmt_descriptors[0];
  1696.     if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)
  1697.         return prev + 1;
                ^
  1698.     return NULL;
  1699. }

libavutil/pixdesc.c:1699:1: return from a call to av_pix_fmt_desc_next
  1697.         return prev + 1;
  1698.     return NULL;
  1699. }
        ^
  1700. 
  1701. 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:1701:1: start of procedure av_pix_fmt_desc_get_id()
  1699. }
  1700. 
  1701. enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
        ^
  1702. {
  1703.     if (desc < av_pix_fmt_descriptors ||

libavutil/pixdesc.c:1703:9: Taking false branch
  1701. enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
  1702. {
  1703.     if (desc < av_pix_fmt_descriptors ||
                ^
  1704.         desc >= av_pix_fmt_descriptors + FF_ARRAY_ELEMS(av_pix_fmt_descriptors))
  1705.         return AV_PIX_FMT_NONE;

libavutil/pixdesc.c:1704:9: Taking false branch
  1702. {
  1703.     if (desc < av_pix_fmt_descriptors ||
  1704.         desc >= av_pix_fmt_descriptors + FF_ARRAY_ELEMS(av_pix_fmt_descriptors))
                ^
  1705.         return AV_PIX_FMT_NONE;
  1706. 

libavutil/pixdesc.c:1707:5: 
  1705.         return AV_PIX_FMT_NONE;
  1706. 
  1707.     return desc - av_pix_fmt_descriptors;
            ^
  1708. }
  1709. 

libavutil/pixdesc.c:1708:1: return from a call to av_pix_fmt_desc_get_id
  1706. 
  1707.     return desc - av_pix_fmt_descriptors;
  1708. }
        ^
  1709. 
  1710. int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt,

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:1692:1: start of procedure av_pix_fmt_desc_next()
  1690. }
  1691. 
  1692. const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
        ^
  1693. {
  1694.     if (!prev)

libavutil/pixdesc.c:1694:10: Taking false branch
  1692. const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
  1693. {
  1694.     if (!prev)
                 ^
  1695.         return &av_pix_fmt_descriptors[0];
  1696.     if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)

libavutil/pixdesc.c:1696:9: Taking true branch
  1694.     if (!prev)
  1695.         return &av_pix_fmt_descriptors[0];
  1696.     if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)
                ^
  1697.         return prev + 1;
  1698.     return NULL;

libavutil/pixdesc.c:1697:9: 
  1695.         return &av_pix_fmt_descriptors[0];
  1696.     if (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1)
  1697.         return prev + 1;
                ^
  1698.     return NULL;
  1699. }

libavutil/pixdesc.c:1699:1: return from a call to av_pix_fmt_desc_next
  1697.         return prev + 1;
  1698.     return NULL;
  1699. }
        ^
  1700. 
  1701. 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: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. 
