coverity#1202814 Overflowed return value

Change-Id: Ifc07a0b3f09dc1209e434056eb007a4401a09d3e
coverity#705845 Dereference before null

Change-Id: I4aecc132ca45abd45183455c87be4c4a3749d983