(a) Except as provided in subsection (b) of this section, a person who has been released on habeas corpus may not be imprisoned or committed in connection with the same offense.
(b) A person who has been released on habeas corpus may be imprisoned or committed in connection with the same offense:
(1) By order of the court for violation of the terms of his release;
(2) By order of any court having jurisdiction over the case;
(3) Upon surrender by his bondsman; or
(4) Upon his conviction.