Fix: Check attempt counter is invalid.

Fixes #5734