Fixing #LANG-294. The indexOf method did not take into account the size variable that limited the amount of the buffer that should be looked at.