Commit 594aea05 authored by posciak@chromium.org's avatar posciak@chromium.org

VAVDA: Fix a crash if we fail parsing SPS/DecodeInitial.

If SPS has unsupported parameters, we get overzealous by attempting to destroy
a not-yet-created VA context causing a crash in the driver.


Review URL: https://chromiumcodereview.appspot.com/10823246

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150712 0039d316-1c4b-4281-b951-d872f2087c98
parent 91375140
......@@ -323,6 +323,7 @@ VaapiH264Decoder::VaapiH264Decoder() {
max_pic_order_cnt_lsb_ = 0;
state_ = kUninitialized;
num_available_decode_surfaces_ = 0;
va_context_created_ = false;
}
VaapiH264Decoder::~VaapiH264Decoder() {
......@@ -584,6 +585,8 @@ bool VaapiH264Decoder::CreateVASurfaces() {
return false;
}
va_context_created_ = true;
return true;
}
......@@ -591,12 +594,18 @@ void VaapiH264Decoder::DestroyVASurfaces() {
DCHECK(state_ == kDecoding || state_ == kError || state_ == kAfterReset);
decode_surfaces_.clear();
// This can happen if we fail during DecodeInitial.
if (!va_context_created_)
return;
VAStatus va_res = VAAPI_DestroyContext(va_display_, va_context_id_);
VA_LOG_ON_ERROR(va_res, "vaDestroyContext failed");
va_res = VAAPI_DestroySurfaces(va_display_, va_surface_ids_,
GetRequiredNumOfPictures());
VA_LOG_ON_ERROR(va_res, "vaDestroySurfaces failed");
va_context_created_ = false;
}
void VaapiH264Decoder::DestroyPendingBuffers() {
......
......@@ -333,6 +333,7 @@ class VaapiH264Decoder {
VAConfigID va_config_id_;
VAContextID va_context_id_;
VAProfile profile_;
bool va_context_created_;
// Allocated VASurfaces.
VASurfaceID va_surface_ids_[kNumReqPictures];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment