Add protection for wrong API call without initialize
Showing the changes to codec/decoder/plus/src/welsDecoderExt.cpp (1 of 1 file). Show all
Unified · Split
| @@ -444,6 +444,13 @@ DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc, · 443 unmodified lines | |||
| 444 | const int kiSrcLen, | 444 | const int kiSrcLen, |
| 445 | unsigned char** ppDst, | 445 | unsigned char** ppDst, |
| 446 | SBufferInfo* pDstInfo) { | 446 | SBufferInfo* pDstInfo) { |
| 447 | if (m_pDecContext == NULL || m_pDecContext->pParam == NULL) { | ||
| 448 | if (m_pWelsTrace != NULL) { | ||
| 449 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "Call DecodeFrame2 without Initialize.\n"); | ||
| 450 | } | ||
| 451 | return dsInitialOptExpected; | ||
| 452 | } | ||
| 453 | |||
| 447 | if (m_pDecContext->pParam->bParseOnly) { | 454 | if (m_pDecContext->pParam->bParseOnly) { |
| 448 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "bParseOnly should be false for this API calling! \n"); | 455 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "bParseOnly should be false for this API calling! \n"); |
| 449 | m_pDecContext->iErrorCode |= dsInvalidArgument; | 456 | m_pDecContext->iErrorCode |= dsInvalidArgument; |
| @@ -590,6 +597,13 @@ DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc, · 140 unmodified lines | |||
| 590 | DECODING_STATE CWelsDecoder::DecodeParser (const unsigned char* kpSrc, | 597 | DECODING_STATE CWelsDecoder::DecodeParser (const unsigned char* kpSrc, |
| 591 | const int kiSrcLen, | 598 | const int kiSrcLen, |
| 592 | SParserBsInfo* pDstInfo) { | 599 | SParserBsInfo* pDstInfo) { |
| 600 | if (m_pDecContext == NULL || m_pDecContext->pParam == NULL) { | ||
| 601 | if (m_pWelsTrace != NULL) { | ||
| 602 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "Call DecodeParser without Initialize.\n"); | ||
| 603 | } | ||
| 604 | return dsInitialOptExpected; | ||
| 605 | } | ||
| 606 | |||
| 593 | if (!m_pDecContext->pParam->bParseOnly) { | 607 | if (!m_pDecContext->pParam->bParseOnly) { |
| 594 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "bParseOnly should be true for this API calling! \n"); | 608 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "bParseOnly should be true for this API calling! \n"); |
| 595 | m_pDecContext->iErrorCode |= dsInvalidArgument; | 609 | m_pDecContext->iErrorCode |= dsInvalidArgument; |