Merge "Fix potential overflows"
am: a0c1eb865f

Change-Id: I4915dcf9cebb84ad5f9ba28c0fae0a7ba85291ac