
139 Cal.App.3d 678 (1983)
188 Cal. Rptr. 866
In re DANA G., a Minor, on Habeas Corpus.
Docket No. AO20446.
Court of Appeals of California, First District, Division Four.
February 2, 1983.
*679 COUNSEL
John Murcko, under appointment by the Court of Appeal, for Petitioner.
John K. Van de Kamp, Attorney General, Daniel J. Kremer, Chief Assistant Attorney General, William D. Stein, Assistant Attorney General, Kristofer Jorstad and Mary A. Roth, Deputy Attorneys General, for Respondent.
OPINION
CALDECOTT, P.J.
Petitioner, a minor who is confined in Ventura County, seeks immediate release from the California Youth Authority. Since there is no territorial limitation on the exercise of habeas corpus jurisdiction and since the attack is upon a judgment rendered in Contra Costa County, jurisdiction is appropriate in this court. (Griggs v. Superior Court (1976) 16 Cal.3d 341, 346-347, 356 [128 Cal. Rptr. 223, 546 P.2d 727].)
On September 10, 1981, wardship proceedings were commenced in action No. 62264 by a petition under section 602 of the Welfare and Institutions Code, *680 charging petitioner with two misdemeanors  loitering and giving false information to a police officer  and two infractions  wilfully and unlawfully standing in a roadway and pedestrian running in front of vehicle. Petitioner admitted loitering and giving false information. She was committed to the California Youth Authority upon the filing of a supplemental petition pursuant to Welfare and Institutions Code section 777, after previous less restrictive dispositions, one at home and one at St. Elizabeth's Home for Girls in San Francisco.
Petitioner's term of commitment was fixed at two years by adding to the term for the misdemeanor charge of giving false information, the unspent custody time from two prior wardships in action Nos. 58391 and 59527. Petitioner contends that her term of commitment cannot include unserved custody time from prior terminated wardships. We conclude that she is correct.
The Attorney General argues that Welfare and Institutions Code section 726 specifically provides for the procedure used here, citing the following portion of that section: "In any case in which the minor is removed from the physical custody of his parent or guardian as the result of an order of wardship made pursuant to Section 602, the order shall specify that the minor may not be held in physical confinement for a period in excess of the maximum term of imprisonment which could be imposed upon an adult convicted of the offense or offenses which brought or continued the minor under the jurisdiction of the juvenile court....
"If the court elects to aggregate the period of physical confinement on multiple counts, or multiple petitions, including previously sustained petitions adjudging the minor a ward within Section 602, the `maximum term of imprisonment' shall be specified in accordance with subdivision (a) of Section 1170.1 of the Penal Code." (Italics added.)
(1) It is clear that this section permits the aggregation of all charges against a minor when the petitions or supplemental petitions containing these charges have not been dismissed. (See, e.g., In re Michael B. (1980) 28 Cal. App.3d 548 [169 Cal. Rptr. 723, 620 P.2d 173]; In re Robert S. (1979) 92 Cal. App.3d 355, 360 [154 Cal. Rptr. 832]; In re Aaron N. (1977) 70 Cal. App.3d 931 [139 Cal. Rptr. 258].) The section, however, not only permits aggregation but requires a maximum term of confinement no longer than the maximum term of imprisonment which could be imposed upon an adult convicted of the offense or offenses. If the juvenile court aggregated unspent time on petitions which had been dismissed, this latter requirement of the section would not be met. An adult may not have his term increased by unspent custody time on dismissed charges. When the adult is released from his custody and parole time, he cannot be required to serve any unserved time on a new charge.
*681 The Attorney General argues that an interpretation of section 726, to distinguish between past offenses on the basis of whether the petition was vacated "makes no sense in the context of the juvenile court law." To the contrary, however, the distinction is consistent with the legislative scheme. The juvenile court may maintain jurisdiction over the juvenile who has been made a ward of the court until the juvenile is 21 or 23, depending upon the juvenile's age when he committed the offense. When the juvenile court is convinced that wardship is no longer necessary, it has a duty to release the juvenile from its jurisdiction. (See In re Syson (1960) 184 Cal. App.2d 111, 117 [7 Cal. Rptr. 298].) Once released, jurisdiction may only be gained by the filing of a new petition. If, however, the juvenile court retains jurisdiction, it may modify or change its previous order to require the serving of unserved time.
The only offense on which petitioner was given commitment time in action No. 62264 was a violation of Vehicle Code section 31, which carries a maximum commitment time of six months (Veh. Code, § 42002). Petitioner has been committed well beyond that time and thus is entitled to immediate release. The Attorney General has stipulated that his opposition to the petition may constitute the return to the petition. There are no factual disputes in regard to the issue here determined. We, therefore, grant habeas corpus relief without the issuance of an order to show cause.
The Director of the California Youth Authority is ordered to release petitioner forthwith.
Christian, J., and Poche, J., concurred.
