If a judgment against the defendant is reversed without ordering a new trial, the supreme court, if the defendant is in custody, shall direct that the defendant be discharged therefrom, or if on bail, that the defendant's bail be exonerated, or if money was deposited instead of bail, that it be refunded to the defendant.
N.D.C.C. § 29-28-30