summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Rataj <rataj28@gmail.com>2017-07-27 10:54:00 +0000
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2017-08-01 16:23:22 +0200
commitc18130890418a9fb0665de0c873150dd8cee9379 (patch)
tree50a82c48fb11b402b4be28d467cb915b3d9fffaa
parentaa3543929b163ea959937bca8262ffb991e701a4 (diff)
libs: display: when appending formats change pointers to indexes
Thus, it fixes an invalid read when YV12 or I420 are not supported by the driver. https://bugzilla.gnome.org/show_bug.cgi?id=785085
-rw-r--r--gst-libs/gst/vaapi/gstvaapidisplay.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapidisplay.c b/gst-libs/gst/vaapi/gstvaapidisplay.c
index 73da04eb..bf23ccb6 100644
--- a/gst-libs/gst/vaapi/gstvaapidisplay.c
+++ b/gst-libs/gst/vaapi/gstvaapidisplay.c
@@ -209,13 +209,13 @@ append_formats (GArray * formats, const VAImageFormat * va_formats,
guint * flags, guint n)
{
GstVideoFormat format;
- const GstVaapiFormatInfo *YV12_fip = NULL;
- const GstVaapiFormatInfo *I420_fip = NULL;
+ int YV12_idx = -1;
+ int I420_idx = -1;
+ const GstVaapiFormatInfo *fip;
guint i;
for (i = 0; i < n; i++) {
const VAImageFormat *const va_format = &va_formats[i];
- const GstVaapiFormatInfo **fipp;
format = gst_vaapi_video_format_from_va_format (va_format);
if (format == GST_VIDEO_FORMAT_UNKNOWN) {
@@ -227,25 +227,25 @@ append_formats (GArray * formats, const VAImageFormat * va_formats,
switch (format) {
case GST_VIDEO_FORMAT_YV12:
- fipp = &YV12_fip;
+ YV12_idx = formats->len - 1;
break;
case GST_VIDEO_FORMAT_I420:
- fipp = &I420_fip;
+ I420_idx = formats->len - 1;
break;
default:
- fipp = NULL;
break;
}
- if (fipp)
- *fipp = &g_array_index (formats, GstVaapiFormatInfo, formats->len - 1);
}
/* Append I420 (resp. YV12) format if YV12 (resp. I420) is not
supported by the underlying driver */
- if (YV12_fip && !I420_fip)
- append_format (formats, GST_VIDEO_FORMAT_I420, YV12_fip->flags);
- else if (I420_fip && !YV12_fip)
- append_format (formats, GST_VIDEO_FORMAT_YV12, I420_fip->flags);
+ if ((YV12_idx != -1) && (I420_idx == -1)) {
+ fip = &g_array_index (formats, GstVaapiFormatInfo, YV12_idx);
+ append_format (formats, GST_VIDEO_FORMAT_I420, fip->flags);
+ } else if ((I420_idx != -1) && (YV12_idx == -1)) {
+ fip = &g_array_index (formats, GstVaapiFormatInfo, I420_idx);
+ append_format (formats, GST_VIDEO_FORMAT_YV12, fip->flags);
+ }
}
/* Sort image formats. Prefer YUV formats first */