ref: 2273624a6a0d30f2359a8f706f2d47e94bd8c4c6
parent: d7b344f18de68e52bd5fa4a02a762bf192831c79
parent: e90068c234a8f93df01b30b0d3de9ca8d8915c1d
author: HaiboZhu <[email protected]>
date: Tue Aug 11 18:52:28 EDT 2015
Merge pull request #2070 from HaiboZhu/Bugfix_Emulation_prevention_three_byte Add protection about emulation_prevention_three_byte error bytes
--- a/codec/decoder/core/src/decoder.cpp
+++ b/codec/decoder/core/src/decoder.cpp
@@ -669,10 +669,15 @@
(0 == LD16 (pSrcNal + iSrcIdx)) &&
((pSrcNal[2 + iSrcIdx] == 0x03) || (pSrcNal[2 + iSrcIdx] == 0x01))) {
if (pSrcNal[2 + iSrcIdx] == 0x03) {
- ST16 (pDstNal + iDstIdx, 0);
- iDstIdx += 2;
- iSrcIdx += 3;
- iSrcConsumed += 3;
+ if ((3 + iSrcConsumed < iSrcLength) && pSrcNal[3 + iSrcIdx] > 0x03) {
+ pCtx->iErrorCode |= dsBitstreamError;
+ return pCtx->iErrorCode;
+ } else {
+ ST16 (pDstNal + iDstIdx, 0);
+ iDstIdx += 2;
+ iSrcIdx += 3;
+ iSrcConsumed += 3;
+ }
} else {
iConsumedBytes = 0;