[jpegd]: Fix jpeg decoder MppBuffer crash

1. Fix jpeg decoder error on release.
2. Fix possible crash when release invalid MppBuffer handle.

Change-Id: Ie904192af3352b5f967dcea6371bdb9aff194089
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
This commit is contained in:
Herman Chen
2016-12-13 16:05:59 +08:00
parent f1e92dee6f
commit 447bb9e951
2 changed files with 12 additions and 15 deletions

View File

@@ -325,7 +325,8 @@ MPP_RET mpp_buffer_ref_dec(MppBufferImpl *buffer, const char* caller)
MPP_RET ret = MPP_OK; MPP_RET ret = MPP_OK;
MppBufferGroupImpl *group = SEARCH_GROUP_BY_ID(buffer->group_id); MppBufferGroupImpl *group = SEARCH_GROUP_BY_ID(buffer->group_id);
buffer_group_add_log(group, buffer, BUF_REF_DEC, caller); if (group)
buffer_group_add_log(group, buffer, BUF_REF_DEC, caller);
if (buffer->ref_count <= 0) { if (buffer->ref_count <= 0) {
mpp_err_f("found non-positive ref_count %d caller %s\n", mpp_err_f("found non-positive ref_count %d caller %s\n",
@@ -717,6 +718,8 @@ MppBufferGroupImpl *MppBufferService::get_group_by_id(RK_U32 id)
} }
} }
mpp_err_f("can not find group with id %d\n", id);
return NULL; return NULL;
} }

View File

@@ -838,9 +838,7 @@ void *mpp_dec_advanced_thread(void *data)
MppTask mpp_task = NULL; MppTask mpp_task = NULL;
MPP_RET ret = MPP_OK; MPP_RET ret = MPP_OK;
MppFrame frame = NULL; MppFrame frame = NULL;
MppFrame tmp_frame = NULL;
MppPacket packet = NULL; MppPacket packet = NULL;
mpp_frame_init(&tmp_frame);
while (MPP_THREAD_RUNNING == thd_dec->get_status()) { while (MPP_THREAD_RUNNING == thd_dec->get_status()) {
thd_dec->lock(); thd_dec->lock();
@@ -915,13 +913,14 @@ void *mpp_dec_advanced_thread(void *data)
mpp_hal_hw_start(dec->hal, &pTask->info); mpp_hal_hw_start(dec->hal, &pTask->info);
mpp_hal_hw_wait(dec->hal, &pTask->info); mpp_hal_hw_wait(dec->hal, &pTask->info);
mpp_buf_slot_get_prop(frame_slots, task_dec->output, SLOT_FRAME, &tmp_frame); MppFrame tmp = NULL;
mpp_frame_set_width(frame, mpp_frame_get_width(tmp_frame)); mpp_buf_slot_get_prop(frame_slots, task_dec->output, SLOT_FRAME_PTR, &tmp);
mpp_frame_set_height(frame, mpp_frame_get_height(tmp_frame)); mpp_frame_set_width(frame, mpp_frame_get_width(tmp));
mpp_frame_set_hor_stride(frame, mpp_frame_get_hor_stride(tmp_frame)); mpp_frame_set_height(frame, mpp_frame_get_height(tmp));
mpp_frame_set_ver_stride(frame, mpp_frame_get_ver_stride(tmp_frame)); mpp_frame_set_hor_stride(frame, mpp_frame_get_hor_stride(tmp));
mpp_frame_set_pts(frame, mpp_frame_get_pts(tmp_frame)); mpp_frame_set_ver_stride(frame, mpp_frame_get_ver_stride(tmp));
mpp_frame_set_fmt(frame, mpp_frame_get_fmt(tmp_frame)); mpp_frame_set_pts(frame, mpp_frame_get_pts(tmp));
mpp_frame_set_fmt(frame, mpp_frame_get_fmt(tmp));
mpp_buf_slot_clr_flag(packet_slots, task_dec->input, SLOT_HAL_INPUT); mpp_buf_slot_clr_flag(packet_slots, task_dec->input, SLOT_HAL_INPUT);
mpp_buf_slot_clr_flag(frame_slots, task_dec->output, SLOT_HAL_OUTPUT); mpp_buf_slot_clr_flag(frame_slots, task_dec->output, SLOT_HAL_OUTPUT);
@@ -961,11 +960,6 @@ void *mpp_dec_advanced_thread(void *data)
dec_release_task_in_port(input); dec_release_task_in_port(input);
dec_release_task_in_port(mpp->mOutputPort); dec_release_task_in_port(mpp->mOutputPort);
if (tmp_frame) {
mpp_frame_deinit(&tmp_frame);
tmp_frame = NULL;
}
return NULL; return NULL;
} }