Add a safe check to ensure start index is not negative

Change-Id: I9a6ffcf37882df9bd322296d6ea008b358ec2906
Merge "Add a safe check to ensure start index is not negative" into kitkat