Mr. Jones, the appellant, was convicted in the district court of the crime of robbery and was sentenced to the State Prison where he is now confined. In that case his lawyer prepared an affidavit to be signed by the appellant, but the appellant refused to sign and announced he preferred to be represented by an uneducated so-called “Jail House” lawyer, and that he would file the affidavit and motion pro se.
An affidavit and motion for a new trial were filed with the clerk of the court but were never called up for disposition. Thereafter, some two years later, appellant filed a petition for a writ of habeas corpus. The trial court was of the opinion that the application for the writ of habeas corpus was “moot” since the time for appeal had not expired.1
It appears to us that the time for appeal had not expired, since no ruling had been made on the motion for a new trial. Either party could have called the motion to the attention of the court and had a ruling made thereon. The cause of delay in the matter was not the fault of the appellant as much as it was of the State, for appellant was in prison.
The judgment upon the appellant (defendant in the criminal case) was signed by the trial judge November 29, 1973, and the motion for a new trial was filed timely,2 to wit, on December 3, 1973.
By consent of the parties the trial judge considered the motion for a new trial at the habeas corpus heáring and denied it. In this we think he did not err, since the granting of a new trial is a matter of discretion.
We know of no reason why a writ of habeas corpus cannot be brought any time a person is wrongfully restrained of his freedom, whether it be before or after a trial. However, we have consistently held that matters proper to be heard on appeal cannot be used as a basis for granting a writ of habeas corpus.3 The matters presented in the petition for a writ of ha-beas corpus all were proper for consideration on appeal. The court was therefore correct in refusing to release the appellant on a writ of habeas corpus.
While it is evident that the motion was denied because the trial court thought the matter was moot, nevertheless, we should *196affirm if the ruling was correct, even when the wrong reason is given for it.4
The judgment is affirmed as it affects each case.
HENRIOD, C. J., and CROCKETT, TUCKETT and MAUGHAN, JJ., concur.. Our statute 77-39-5, U.C.A.1953, provides that an' appeal may be taken within one month after notice of the denial of a motion for a new trial.
. 77-38-4, U.C.A.1953.
. Ainslie v. Smith, 531 P.2d 864 (Utah 1975), and cases therein cited.
. Peterson v. Fowler, 29 Utah 2d 366, 510 P.2d 523 (1973) ; 5 C.J.S. Appeal and Error § 1464(1) ; Limb v. Federated Milk, 23 Utah 2d 222, 461 P.2d 290 (1969).