avoid out-of-bounds access when iterating code points

Change-Id: I88290e5ccfd6ab250fe1526e452609e6de020dcd
avoid out-of-bounds access when iterating code points

Change-Id: I583e49180b37705ea124c0d88c2e2a8cb1470dfe