shithub: openh264

Download patch

ref: 336416875301fa3dd19abbf6b56f695ea1864b82
parent: 6d9220c43b74272fab1759a328a27d54f720fafb
author: huili2 <huili2@cisco.com>
date: Tue Nov 22 05:36:13 EST 2016

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);