From d68025cd2000ea6b195b24e03acff838572c223e Mon Sep 17 00:00:00 2001 From: Zhao Yakui Date: Tue, 15 Oct 2013 11:04:00 +0800 Subject: Return the error instead of assert in vaEndPicture This is to fix the crash issue caused by the incorrect parameter. Signed-off-by: Zhao Yakui (cherry picked from commit 1cee858036a87837deddc87586701ed869f96261) --- src/i965_drv_video.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'src/i965_drv_video.c') diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c index 6b81fb0..efe72b4 100755 --- a/src/i965_drv_video.c +++ b/src/i965_drv_video.c @@ -2313,17 +2313,33 @@ i965_EndPicture(VADriverContextP ctx, VAContextID context) } else if (obj_context->codec_type == CODEC_ENC) { assert(VAEntrypointEncSlice == obj_config->entrypoint); - assert(obj_context->codec_state.encode.pic_param || - obj_context->codec_state.encode.pic_param_ext); - assert(obj_context->codec_state.encode.seq_param || - obj_context->codec_state.encode.seq_param_ext); - assert(obj_context->codec_state.encode.num_slice_params >= 1 || - obj_context->codec_state.encode.num_slice_params_ext >= 1); + if (!(obj_context->codec_state.encode.pic_param || + obj_context->codec_state.encode.pic_param_ext)) { + return VA_STATUS_ERROR_INVALID_PARAMETER; + } + if (!(obj_context->codec_state.encode.seq_param || + obj_context->codec_state.encode.seq_param_ext)) { + return VA_STATUS_ERROR_INVALID_PARAMETER; + } + if ((obj_context->codec_state.encode.num_slice_params <=0) && + (obj_context->codec_state.encode.num_slice_params_ext <=0)) { + return VA_STATUS_ERROR_INVALID_PARAMETER; + } } else { - assert(obj_context->codec_state.decode.pic_param); - assert(obj_context->codec_state.decode.num_slice_params >= 1); - assert(obj_context->codec_state.decode.num_slice_datas >= 1); - assert(obj_context->codec_state.decode.num_slice_params == obj_context->codec_state.decode.num_slice_datas); + if (obj_context->codec_state.decode.pic_param == NULL) { + return VA_STATUS_ERROR_INVALID_PARAMETER; + } + if (obj_context->codec_state.decode.num_slice_params <=0) { + return VA_STATUS_ERROR_INVALID_PARAMETER; + } + if (obj_context->codec_state.decode.num_slice_datas <=0) { + return VA_STATUS_ERROR_INVALID_PARAMETER; + } + + if (obj_context->codec_state.decode.num_slice_params != + obj_context->codec_state.decode.num_slice_datas) { + return VA_STATUS_ERROR_INVALID_PARAMETER; + } } assert(obj_context->hw_context->run); -- cgit v1.2.3