Improve getChars() bounds checking and add a test

The dstEnd calculation could previously overflow and a negative
dstBegin wasn't being caught in one specific case.

Bug: 28998511
(cherry picked from commit 6bf866608fbbd6aad37ba0daa288778a6f1fad41)

Change-Id: I9e16f2d2eda4272e6e704d27a10c7acf192349c7
2 files changed