Merge "Avoid possible buffer overflow." am: 5b6c4c4612
am: 9f461fcb2b

Change-Id: Ie47864c9f1f9bfb8a34f276672dffb073d4197b6