shithub: openh264

Download patch

ref: af774e4a52c5bce1f66018990b3f4e67bc7a1937
parent: 8386ac8e37d92a2fa00ae8b18595462babab5a61
author: [email protected] <[email protected]>
date: Mon Feb 6 10:17:46 EST 2017

add protection and remove redundant param

--- a/codec/decoder/core/src/decoder_core.cpp
+++ b/codec/decoder/core/src/decoder_core.cpp
@@ -677,8 +677,8 @@
 
 
 void UpdateDecoderStatisticsForActiveParaset(SDecoderStatistics* pDecoderStatistics,
-                                             PSps pSps, PPps pPps, const int32_t iSpsId) {
-  pDecoderStatistics->iCurrentActiveSpsId = iSpsId;
+                                             PSps pSps, PPps pPps) {
+  pDecoderStatistics->iCurrentActiveSpsId = pSps->iSpsId;
 
   pDecoderStatistics->iCurrentActivePpsId = pPps->iPpsId;
   pDecoderStatistics->uiProfile = static_cast<unsigned int> (pSps->uiProfileIdc);
@@ -2119,8 +2119,7 @@
   pCtx->iFrameNum    = pSh->iFrameNum;
 
   UpdateDecoderStatisticsForActiveParaset(&(pCtx->sDecoderStatistics),
-                                          pSps, pPps,
-                                          (pCurNal->sNalData.sVclNal.bSliceHeaderExtFlag) ? (pCurNal->sNalData.sVclNal.sSliceHeaderExt.pSubsetSps->sSps.iSpsId) : (pSps->iSpsId) );
+                                          pSps, pPps);
 }
 
 int32_t InitRefPicList (PWelsDecoderContext pCtx, const uint8_t kuiNRi, int32_t iPoc) {
--- a/codec/decoder/plus/src/welsDecoderExt.cpp
+++ b/codec/decoder/plus/src/welsDecoderExt.cpp
@@ -347,7 +347,10 @@
              "CWelsDecoder::SetOption():DECODER_OPTION_GET_STATISTICS: this option is get-only!");
     return cmInitParaError;
   } else if (eOptID == DECODER_OPTION_STATISTICS_LOG_INTERVAL) {
-    m_pDecContext->sDecoderStatistics.iStatisticsLogInterval = (* ((unsigned int*)pOption));
+    if (pOption) {
+      m_pDecContext->sDecoderStatistics.iStatisticsLogInterval = (* ((unsigned int*)pOption));
+      return cmResultSuccess;
+    }
   } else if (eOptID == DECODER_OPTION_GET_SAR_INFO) {
     WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING,
              "CWelsDecoder::SetOption():DECODER_OPTION_GET_SAR_INFO: this option is get-only!");
@@ -418,8 +421,11 @@
     }
     return cmResultSuccess;
   } else if (eOptID == DECODER_OPTION_STATISTICS_LOG_INTERVAL) {
-    iVal = m_pDecContext->sDecoderStatistics.iStatisticsLogInterval;
-    * ((unsigned int*)pOption) = iVal;
+    if (pOption) {
+      iVal = m_pDecContext->sDecoderStatistics.iStatisticsLogInterval;
+      * ((unsigned int*)pOption) = iVal;
+      return cmResultSuccess;
+    }
   } else if (DECODER_OPTION_GET_SAR_INFO == eOptID) { //get decoder SAR info in VUI
     PVuiSarInfo pVuiSarInfo = (static_cast<PVuiSarInfo> (pOption));
     memset (pVuiSarInfo, 0, sizeof (SVuiSarInfo));