Added check to avoid buffer overflow.

Bug: 36178213
Bug: 36646774
Test: Manual
Change-Id: I8282b24dabcfe44316db5b719f1e35713f353240
1 file changed