Add bound checks to utf16_to_utf8
am: 37d7af3c3a

Change-Id: Ib0ea8bcca47718cc91fda39d8f1ffe6126590271