don't access past end of string

Change-Id: Ia431f51cb02bbd235cdfe56a8131d7b622e9e311