libs: decoder: h264: Avoid using picture after it has been free

In some cases, the found_picture ended up being evicted and freed, which
would lead to a use after free when accessing picture->base.poc. In this
fix, we take a ref on the picture before calling dpb_evict.

https://bugzilla.gnome.org/show_bug.cgi?id=787124
This commit is contained in:
Nicolas Dufresne 2018-08-27 20:42:15 -04:00
parent 7a120c7a72
commit 2922439bc2

View file

@ -942,16 +942,22 @@ dpb_bump (GstVaapiDecoderH264 * decoder, GstVaapiPictureH264 * picture)
if (found_index < 0)
return FALSE;
gst_vaapi_picture_ref (found_picture);
if (picture && picture->base.poc != found_picture->base.poc)
dpb_output_other_views (decoder, found_picture, found_picture->base.voc);
success = dpb_output (decoder, priv->dpb[found_index]);
dpb_evict (decoder, found_picture, found_index);
if (priv->max_views == 1)
return success;
goto done;
if (picture && picture->base.poc != found_picture->base.poc)
dpb_output_other_views (decoder, found_picture, G_MAXUINT32);
done:
gst_vaapi_picture_unref (found_picture);
return success;
}