Add protection for wrong API call without initialize

This commit is contained in:
Haibo Zhu 2016-01-18 15:48:05 +08:00
parent 91fa9fad63
commit 6d7bd2daf4

@ -444,6 +444,13 @@ DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc,
const int kiSrcLen,
unsigned char** ppDst,
SBufferInfo* pDstInfo) {
if (m_pDecContext == NULL || m_pDecContext->pParam == NULL) {
if (m_pWelsTrace != NULL) {
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "Call DecodeFrame2 without Initialize.\n");
}
return dsInitialOptExpected;
}
if (m_pDecContext->pParam->bParseOnly) {
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "bParseOnly should be false for this API calling! \n");
m_pDecContext->iErrorCode |= dsInvalidArgument;
@ -589,6 +596,13 @@ DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc,
DECODING_STATE CWelsDecoder::DecodeParser (const unsigned char* kpSrc,
const int kiSrcLen,
SParserBsInfo* pDstInfo) {
if (m_pDecContext == NULL || m_pDecContext->pParam == NULL) {
if (m_pWelsTrace != NULL) {
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "Call DecodeParser without Initialize.\n");
}
return dsInitialOptExpected;
}
if (!m_pDecContext->pParam->bParseOnly) {
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "bParseOnly should be true for this API calling! \n");
m_pDecContext->iErrorCode |= dsInvalidArgument;