fixed out of bounds string access

Change-Id: I25f53f16c3ddc3456c165b6c604911433f460228
(cherry picked from commit 40fba2316ac3ebb11b69c157cfac7da92a63821b)