Skip to content

Commit

Permalink
Fix Coverity issues
Browse files Browse the repository at this point in the history
CID/Type:
187157 Explicit null dereferenced
656172 Dereference after null check
602228 Dereference before null check

Tracked-On: OAM-126078
Signed-off-by: Wan, Hao <[email protected]>
  • Loading branch information
harvan authored and sysopenci committed Oct 10, 2024
1 parent a2321db commit 1c6ccea
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
33 changes: 20 additions & 13 deletions c2_components/src/mfx_c2_decoder_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2004,6 +2004,8 @@ void MfxC2DecoderComponent::DoWork(std::unique_ptr<C2Work>&& work)
{
MFX_DEBUG_TRACE_FUNC;

if (!work) return;

if (m_bFlushing) {
m_flushedWorks.push_back(std::move(work));
return;
Expand Down Expand Up @@ -2334,19 +2336,20 @@ void MfxC2DecoderComponent::WaitWork(MfxC2FrameOut&& frame_out, mfxSyncPoint syn

MfxC2FrameOut frameOutVpp;
std::shared_ptr<mfxFrameSurface1> mfx_surface_vpp;
if(m_vppConversion) {
AllocateFrame(&frameOutVpp, true);
mfx_surface_vpp = frameOutVpp.GetMfxFrameSurface();

if (mfx_surface_vpp) {
mfxSyncPoint syncp;
mfx_res = m_vpp->RunFrameVPPAsync(mfx_surface.get(), mfx_surface_vpp.get(), NULL, &syncp);
if (MFX_ERR_NONE == mfx_res)
#ifdef USE_ONEVPL
mfx_res = MFXVideoCORE_SyncOperation(m_mfxSession, syncp, MFX_TIMEOUT_INFINITE);
#else
mfx_res = m_pSession->SyncOperation(syncp, MFX_TIMEOUT_INFINITE);
#endif
if (m_vppConversion) {
res = AllocateFrame(&frameOutVpp, true);
if (res == C2_OK) {
mfx_surface_vpp = frameOutVpp.GetMfxFrameSurface();
if (mfx_surface_vpp.get()) {
mfxSyncPoint syncp;
mfx_res = m_vpp->RunFrameVPPAsync(mfx_surface.get(), mfx_surface_vpp.get(), NULL, &syncp);
if (MFX_ERR_NONE == mfx_res)
#ifdef USE_ONEVPL
mfx_res = MFXVideoCORE_SyncOperation(m_mfxSession, syncp, MFX_TIMEOUT_INFINITE);
#else
mfx_res = m_pSession->SyncOperation(syncp, MFX_TIMEOUT_INFINITE);
#endif
}
}
}

Expand Down Expand Up @@ -2387,6 +2390,10 @@ void MfxC2DecoderComponent::WaitWork(MfxC2FrameOut&& frame_out, mfxSyncPoint syn
rect = C2Rect(mfx_surface->Info.CropW, mfx_surface->Info.CropH)
.at(mfx_surface->Info.CropX, mfx_surface->Info.CropY);
} else {
if (mfx_surface_vpp.get() == nullptr) {
res = C2_CORRUPTED;
break;
}
rect = C2Rect(mfx_surface_vpp->Info.CropW, mfx_surface_vpp->Info.CropH)
.at(mfx_surface_vpp->Info.CropX, mfx_surface_vpp->Info.CropY);
}
Expand Down
7 changes: 5 additions & 2 deletions c2_utils/src/mfx_gralloc1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,16 @@ buffer_handle_t MfxGralloc1Module::ImportBuffer(const buffer_handle_t rawHandle)
MFX_DEBUG_TRACE_FUNC;
c2_status_t res = C2_OK;
buffer_handle_t *outBuffer = nullptr;
int32_t gr1_res = (*m_grImportBufferFunc)(m_gralloc1_dev, rawHandle, outBuffer);
buffer_handle_t out = nullptr;

int32_t gr1_res = (*m_grImportBufferFunc)(m_gralloc1_dev, rawHandle, outBuffer);
if (GRALLOC1_ERROR_NONE != gr1_res || nullptr == outBuffer) {
MFX_DEBUG_TRACE_I32(gr1_res);
res = C2_BAD_STATE;
}
buffer_handle_t out = const_cast<buffer_handle_t>(*outBuffer);

if (outBuffer)
out = const_cast<buffer_handle_t>(*outBuffer);

MFX_DEBUG_TRACE__android_c2_status_t(res);
return out;
Expand Down

0 comments on commit 1c6ccea

Please sign in to comment.