If it appears that the party has legally been committed for a criminal offense, or if the party appears by the testimony offered with the return, or upon the hearing thereof, probably to be guilty of such offense, although the commitment is irregular, the party shall forthwith be remanded to the custody or placed under the restraint from which the party was taken, if the officer or person under whose custody or restraint the party was, is legally entitled thereto; if not so entitled, the party shall be committed to the custody of the officer or person so entitled.
ORS 34.630