libs: decoder: fix a crash issue when get_surface_formats.

Some context does not report any valid format that we can support.
For example, the HEVC 444 12 bits decoder context, all the formats
it reports is not supported now, which make the formats list a NULL
array. We should check that pointer before we use it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/372>
This commit is contained in:
He Junyan 2020-07-31 15:27:38 +08:00
parent 7a9a99d0c4
commit 6ab488475a

View file

@ -1192,6 +1192,8 @@ gst_vaapi_decoder_get_surface_attributes (GstVaapiDecoder * decoder,
if (ret)
attribs.formats = gst_vaapi_context_get_surface_formats (decoder->context);
if (!attribs.formats)
return NULL;
if (attribs.formats->len == 0) {
g_array_unref (attribs.formats);
return NULL;