Skip to content
Permalink
Browse files Browse the repository at this point in the history
clamp index values to fix index overflow in IMA.cpp
  • Loading branch information
antlarr committed Mar 6, 2017
1 parent b62c902 commit 25eb00c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libaudiofile/modules/IMA.cpp
Expand Up @@ -169,7 +169,7 @@ int IMA::decodeBlockWAVE(const uint8_t *encoded, int16_t *decoded)
if (encoded[1] & 0x80)
m_adpcmState[c].previousValue -= 0x10000;

m_adpcmState[c].index = encoded[2];
m_adpcmState[c].index = clamp(encoded[2], 0, 88);

*decoded++ = m_adpcmState[c].previousValue;

Expand Down Expand Up @@ -210,7 +210,7 @@ int IMA::decodeBlockQT(const uint8_t *encoded, int16_t *decoded)
predictor -= 0x10000;

state.previousValue = clamp(predictor, MIN_INT16, MAX_INT16);
state.index = encoded[1] & 0x7f;
state.index = clamp(encoded[1] & 0x7f, 0, 88);
encoded += 2;

for (int n=0; n<m_framesPerPacket; n+=2)
Expand Down

0 comments on commit 25eb00c

Please sign in to comment.