shithub: openh264

Download patch

ref: 61b9ddce8e2e8437babffe6e838b2acc873dc994
parent: 05a95e0ecc08ed39cf5de728f5a8a2d3c72594a3
parent: 336416875301fa3dd19abbf6b56f695ea1864b82
author: huili2 <huili2@cisco.com>
date: Thu Nov 24 04:47:30 EST 2016

Merge pull request #2604 from huili2/parse_ubsan_32shift

fix ubsan warning on 32bit shift using twice 16bit calling

--- a/codec/decoder/core/src/au_parser.cpp
+++ b/codec/decoder/core/src/au_parser.cpp
@@ -1516,11 +1516,18 @@
   WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //timing_info_present_flag
   pVui->bTimingInfoPresentFlag = !!uiCode;
   if (pVui->bTimingInfoPresentFlag) {
-    WELS_READ_VERIFY (BsGetBits (pBsAux, 32, &uiCode)); //num_units_in_tick
-    pVui->uiNumUnitsInTick = uiCode;
+    uint32_t uiTmp = 0;
+    WELS_READ_VERIFY (BsGetBits (pBsAux, 16, &uiCode)); //num_units_in_tick
+    uiTmp = (uiCode << 16);
+    WELS_READ_VERIFY (BsGetBits (pBsAux, 16, &uiCode)); //num_units_in_tick
+    uiTmp |= uiCode;
+    pVui->uiNumUnitsInTick = uiTmp;
     WELS_CHECK_SE_LOWER_WARNING (pVui->uiNumUnitsInTick, 1, "num_units_in_tick");
-    WELS_READ_VERIFY (BsGetBits (pBsAux, 32, &uiCode)); //time_scale
-    pVui->uiTimeScale = uiCode;
+    WELS_READ_VERIFY (BsGetBits (pBsAux, 16, &uiCode)); //time_scale
+    uiTmp = (uiCode << 16);
+    WELS_READ_VERIFY (BsGetBits (pBsAux, 16, &uiCode)); //time_scale
+    uiTmp |= uiCode;
+    pVui->uiTimeScale = uiTmp;
     WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //fixed_frame_rate_flag
     pVui->bFixedFrameRateFlag = !!uiCode;
   }
--- a/codec/decoder/core/src/manage_dec_ref.cpp
+++ b/codec/decoder/core/src/manage_dec_ref.cpp
@@ -369,13 +369,13 @@
   case MMCO_SHORT2UNUSED:
     pPic = WelsDelShortFromListSetUnref (pRefPic, iShortFrameNum);
     if (pPic == NULL) {
-      WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "MMCO_SHORT2UNUSED: delete a empty entry from short term list");
+      WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "MMCO_SHORT2UNUSED: delete an empty entry from short term list");
     }
     break;
   case MMCO_LONG2UNUSED:
     pPic = WelsDelLongFromListSetUnref (pRefPic, uiLongTermPicNum);
     if (pPic == NULL) {
-      WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "MMCO_LONG2UNUSED: delete a empty entry from long term list");
+      WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "MMCO_LONG2UNUSED: delete an empty entry from long term list");
     }
     break;
   case MMCO_SHORT2LONG:
@@ -384,7 +384,7 @@
     }
     pPic = WelsDelShortFromList (pRefPic, iShortFrameNum);
     if (pPic == NULL) {
-      WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "MMCO_LONG2LONG: delete a empty entry from short term list");
+      WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "MMCO_LONG2LONG: delete an empty entry from short term list");
       break;
     }
     WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx);