diff --git a/libAACdec/src/aacdec_hcrs.cpp b/libAACdec/src/aacdec_hcrs.cpp index 1d5aa27..d2bc867 100644 --- a/libAACdec/src/aacdec_hcrs.cpp +++ b/libAACdec/src/aacdec_hcrs.cpp @@ -367,7 +367,10 @@ static UINT InitSegmentBitfield(UINT *pNumSegment, UINT tempWord; USHORT numValidSegment; - *pNumWordForBitfield = ((*pNumSegment - 1) >> THIRTYTWO_LOG_DIV_TWO_LOG) + 1; + *pNumWordForBitfield = + (*pNumSegment == 0) + ? 0 + : ((*pNumSegment - 1) >> THIRTYTWO_LOG_DIV_TWO_LOG) + 1; /* loop over all words, which are completely used or only partial */ /* bit in pSegmentBitfield is zero if segment is empty; bit in