Section 123(1) in The Code of Criminal Procedure, 1973
(1)Whenever [the District Magistrate in the case of an order passed by an Executive Magistrate under section 117, or the Chief Judicial Magistrate in any other case] [Substituted by Act 45 of 1978, Section 12, for "the Chief Judicial Magistrate", w.e.f. 18.12.1978.] is of opinion that any person imprisoned for failing to give security under this Chapter may be released without hazard to the community or to any other person, he may order such person to be discharged.