Fix incorrect task index bounds

Should have been using min, not max. Added lower bound for good measure.

Bug: 138025252
Change-Id: Icd8c7d62dca7605fe63e83602e4c9fceb91f68a6
1 file changed