Add bound checks to utf16_to_utf8
am: 9b39ebe132

Change-Id: Ia3ce9b64333983799c6fdb3c5f7383852abda32e