Petitioner is an inmate of the State prison at Jackson. He was sent to that institution December 14, 1894, for a term of 10 years. He admits that prior to this time he had served a term of imprisonment in that institution of 1 year. If petitioner is now serving his second term in said prison, his allowance of time for good *528conduct, under section 2112, 1 Comp. Laws, entitles him to his freedom. It is claimed, however, that petitioner had served his second term before his present term of imprisonment commenced. If this is true, his detention is legal, for section 2112, 1 Comp. Laws, provides:
“If any convict has already served a second term in said prison, he shall be allowed no good time, but shall be held until the full completion of his sentence.”
The facts upon which said claim is based are these: Before petitioner was convicted of the offense for which he is now being punished, he served four terms of imprisonment in the State house of correction and reformatory at Ionia. That a term of imprisonment in that institution is “ a term in said prison,” under the proper construction of section 2112, was determined by this court in the unreported case of Armstrong (decided in 1898) and in Re Coy, 10 Det. L. N. 557. Each of these terms of imprisonment in the Ionia institution was 90 days in length. He was sentenced to one of these terms of imprisonment by a circuit judge. He was sentenced to each of the other three by a justice of the peace. The offense of which he was convicted in each case was that of assault and battery. Neither the justice of the peace (see In re Silverthorn, 73 Mich. 644 [41 N. W. 834]) nor the circuit judge (see Brown v. People, 39 Mich. 57) had jurisdiction to impose this punishment.
In determining what term of imprisonment petitioner is now serving, shall we count any of these terms spent in the Ionia institution ? The imprisonment in that institution was justified by no law. It was sufficiently illegal to be open to collateral attack by a writ of habeas corpus. See In re Silverthorn, supra. One is not “serving a term,” within the meaning of the act, when he is detained in prison without warrant of law. We think it obvious that the legislature intended to deprive the convict serving his third term of the benefit of all allowance for good time because he had twice been found guilty of a crime punishable by imprisonment in a State prison, and received such *529punishment therefor. Until he has been twice convicted of such an offense, a convict cannot serve his second term, within the meaning of the act. Under the contrary construction, the convict loses the good time, not through any fault of his, but through the mistake of the judge who sentenced him. When he served a sentence which was in at least one sense unlawful, he paid a sufficient penalty for this mistake. His misfortune should not be doubled, as it would be if he were deprived of his good-time allowance.
The petitioner should be discharged.
The other Justices concurred.