Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Commit 29014f9

Browse files
authored
Merge pull request #772 from daijh/fix-static-code-scan-issues
Fix static code scan issues
2 parents 3161390 + c5d2c6e commit 29014f9

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

source/core/owt_base/LiveStreamIn.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,10 @@ bool LiveStreamIn::parse_avcC(AVPacket *pkt) {
10831083

10841084
int nals_buf_length = 128;
10851085
uint8_t *nals_buf = (uint8_t *)malloc(nals_buf_length);
1086+
if (nals_buf == nullptr) {
1087+
ELOG_ERROR_T("OOM! Allocate size %d", nals_buf_length);
1088+
return false;
1089+
}
10861090

10871091
int i, cnt, nalsize;
10881092
const uint8_t *p = data;
@@ -1114,6 +1118,10 @@ bool LiveStreamIn::parse_avcC(AVPacket *pkt) {
11141118

11151119
nals_buf_length += nalsize + 4;
11161120
nals_buf = (uint8_t *)realloc(nals_buf, nals_buf_length);
1121+
if (nals_buf == nullptr) {
1122+
ELOG_ERROR_T("OOM! Allocate size %d", nals_buf_length);
1123+
return false;
1124+
}
11171125
}
11181126

11191127
nals_buf[nals_size] = 0;

source/core/owt_base/MsdkFrame.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,15 @@ void MsdkFrame::sync(void)
142142

143143
m_needSync = false;
144144

145-
if (!m_mainSession && !(m_mainSession = MsdkBase::get()->getMainSession())) {
146-
ELOG_ERROR("Invalid main session!");
147-
148-
return;
145+
if (!m_mainSession) {
146+
MsdkBase *msdkBase = MsdkBase::get();
147+
if (msdkBase)
148+
m_mainSession = msdkBase->getMainSession();
149+
150+
if (!m_mainSession) {
151+
ELOG_ERROR("Invalid main session!");
152+
return;
153+
}
149154
}
150155

151156
sts = m_mainSession->SyncOperation(m_syncP, MFX_INFINITE);

source/core/owt_base/MsdkFrameDecoder.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,12 @@ void MsdkFrameDecoder::updateBitstream(const Frame& frame)
417417
memset((void *)m_bitstream.get(), 0, sizeof(mfxBitstream));
418418

419419
m_bitstream->Data = (mfxU8 *)malloc(size);
420+
if (m_bitstream->Data == nullptr) {
421+
m_bitstream.reset();
422+
ELOG_ERROR_T("OOM! Allocate size %d", size);
423+
return;
424+
}
425+
420426
m_bitstream->MaxLength = size;
421427
m_bitstream->DataOffset = 0;
422428
m_bitstream->DataLength = 0;
@@ -450,6 +456,12 @@ void MsdkFrameDecoder::updateBitstream(const Frame& frame)
450456
);
451457

452458
m_bitstream->Data = (mfxU8 *)realloc(m_bitstream->Data, newSize);
459+
if (m_bitstream->Data == nullptr) {
460+
m_bitstream.reset();
461+
ELOG_ERROR_T("OOM! Allocate size %d", newSize);
462+
return;
463+
}
464+
453465
m_bitstream->MaxLength = newSize;
454466
}
455467

source/core/owt_base/MsdkFrameEncoder.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,10 @@ class StreamEncoder : public FrameSource, public JobTimerListener
512512
#endif
513513

514514
#if (MFX_VERSION >= 1025)
515-
uint32_t MFE_timeout = MsdkBase::get()->getConfigMFETimeout();
515+
uint32_t MFE_timeout = 0;
516+
MsdkBase *msdkBase = MsdkBase::get();
517+
if (msdkBase)
518+
MFE_timeout = msdkBase->getConfigMFETimeout();
516519
if (MFE_timeout) {
517520
// MFX_EXTBUFF_MULTI_FRAME_PARAM
518521
m_encExtMultiFrameParam.reset(new mfxExtMultiFrameParam);

0 commit comments

Comments
 (0)