you have to check len before accsessing "p".
Merge pull request #140 from ledyba/check_data_len

you have to check len before accsessing "p".