gsm_7bit_decode: Handle the case of the last charachter being an escape

If i + 1 == length and it is an escape charachter we would try
to read rtext[length] which is one after the field we have allocated.
This commit is contained in:
Holger Hans Peter Freyther 2010-07-20 02:54:54 +08:00
parent 31e97ea34e
commit 446bf37698
1 changed files with 1 additions and 1 deletions

View File

@ -65,7 +65,7 @@ int gsm_7bit_decode(char *text, const uint8_t *user_data, uint8_t length)
}
for(i = 0; i < length; i++){
/* this is an extension character */
if(rtext[i] == 0x1b){
if(rtext[i] == 0x1b && i + 1 < length){
tmp = rtext[i+1];
*(text++) = gsm_7bit_alphabet[0x7f + tmp];
i++;