The second case rtcb->sched_priority <= htcb->sched_priority did not check if there is sufficient space in the pend_reprios array.
The second case rtcb->sched_priority <= htcb->sched_priority did not check if there is sufficient space in the pend_reprios array.