ref: 8eb4de10a2c619db02fb98ce51b3fd3bf1d251c8
parent: 5e3e975ffb600727e760aabcb58c5e8d9f47cbcd
parent: 6d7bd2daf4a49762fd24cdd37d56a7a36dc19542
author: HaiboZhu <haibozhu@cisco.com>
date: Tue Jan 19 08:42:49 EST 2016
Merge pull request #2337 from HaiboZhu/Add_Protection_wrong_API_call Add protection for wrong API call without initialize
--- a/codec/decoder/plus/src/welsDecoderExt.cpp
+++ b/codec/decoder/plus/src/welsDecoderExt.cpp
@@ -444,6 +444,13 @@
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;
@@ -590,6 +597,13 @@
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;