
76 Cal.App.3d 324 (1977)
142 Cal. Rptr. 798
THE PEOPLE, Plaintiff and Respondent,
v.
IRVING SCHULER, Defendant and Appellant.
Docket No. 15838.
Court of Appeals of California, First District, Division Two.
December 29, 1977.
*327 COUNSEL
Paul N. Halvonik, State Public Defender, under appointment by the Court of Appeal, Clifton R. Jeffers, Chief Assistant State Public Defender, Ezra Hendon, Michael G. Millman and Linda S. Feldman, Deputy State Public Defenders, for Defendant and Appellant.
Evelle J. Younger, Attorney General, Jack R. Winkler, Chief Assistant Attorney General, Edward P. O'Brien, Assistant Attorney General, Timothy A. Reardon and John W. Runde, Deputy Attorneys General, for Plaintiff and Respondent.
OPINION
CHAPMAN, J.[*]
In this appeal we determine the application of Penal Code section 2900.5 in a complicated, broken plea bargain case.[1]
Stated as simply as possible, defendant, Irving Schuler, was arrested in Oakland, California, on October 1, 1969. Between that date and April 21, 1970, and while defendant remained in custody, six separate felony informations were filed in the Alameda County Superior Court charging defendant with a total of eleven separate felony offenses which had occurred prior to his arrest. Pursuant to a plea bargain,[2] he pleaded guilty to two of the offenses and was sent to prison to serve concurrent terms.[3] The remaining charges were dismissed as part of the negotiated plea.[4]
*328 Defendant served 785 days in prison pursuant to these convictions, and was then released on parole. The parole was not a success. On March 16, 1973, an information, No. 54911, was filed in the Alameda County Superior Court charging defendant with four counts of robbery (Pen. Code, § 211). As to each count it was alleged that during the course of the robbery, defendant was armed with and used a firearm (Pen. Code, § 12022.5).
While awaiting trial on the new offenses, defendant brought a writ of habeas corpus, as a result of which the convictions for which he had been sent to prison were found to be constitutionally invalid. Whereupon, all of the original 11 counts set forth in the 6 separate informations were reinstated.
Defendant was then tried and convicted of the four counts of robbery committed while he was on parole. As to each such count the allegation that he was armed with and used a firearm was found to be true.[5] Following the trial, defendant entered into a second plea bargain as to the eleven original offenses, pursuant to which he pleaded guilty to four of them, and seven were dismissed.[6]
None of the four counts to which defendant pleaded guilty in the second plea bargain were the same offenses as the two counts in the first plea bargain.
Following the second plea bargain, the entire matter was referred to the Probation Department, and on June 7, 1973, defendant was sentenced to prison on the eight counts of felony violation. The terms have been ordered to run concurrently.[7]
*329 Defendant has been given credit for all the time he has spent in custody as an unsentenced prisoner.[8] He has been given no credit at all for the time he spent in prison on the two counts that were subsequently dismissed as part of the second plea bargain. He now contends he is entitled to credit for that time.

Application of Penal Code section 2900.5.
At the outset we make it clear that this appeal does not in anyway affect the sentences imposed in information No. 54911. Defendant asks credit for the time he spent in prison only as to those offenses which occurred prior to his arrest on October 1, 1969. He does not, nor could he ask credit for such prison time as to offenses that occurred thereafter, while he was on parole.
Defendant has presented several arguments in support of his assertion that he is entitled to credit for the time he spent in prison pursuant to charges that have since been dismissed, but primarily he relies on Penal Code section 2900.5.[9]
Section 2900.5, to the extent it is applicable herein, provides: "(a) In all felony ... convictions, either by plea or by verdict, when the defendant has been in custody, including but not limited to any time *330 spent in a jail, camp, work furlough facility, halfway house, rehabilitation facility, hospital, prison, or similar institution, all days of custody of the defendant ... shall be credited upon his sentence, ... [¶] (b) For the purposes of this section, credit shall be given only where the custody to be credited is attributable to proceedings relating to the same conduct for which the defendant has been convicted. [¶] (c) For the purposes of this section, `sentence' includes ... any term of imprisonment, including any period of imprisonment prior to release on parole and any period of imprisonment and parole, prior to discharge, ... [¶] (d) It shall be the duty of the court imposing the sentence to determine the total number of days to be credited pursuant to the provisions of this section. The total number of days to be credited shall be contained in the abstract of judgment provided for in Section 1213." (Italics added.)
The Attorney General contends that section 2900.5 cannot apply because the express language of subdivision (b) limits the application of the section to credit for time in custody attributable to proceedings relating to the same conduct for which defendant has been convicted. The Attorney General asserts that the 785 days defendant spent in prison were attributable to offenses which have since been dismissed and cannot be attributable to offenses of which defendant now stands convicted.
While at first blush this assertion may appear to have merit, it overlooks the fact that time in custody pursuant to a judgment of conviction may also be attributable to other charges pending trial or awaiting judgment.
(1) It is a basic rule that where an accused person is held in custody on a number of charges and upon conviction he is ordered to serve concurrent sentences, the time to be credited pursuant to section 2900.5 must be credited to each of them. (55 Ops.Cal.Atty.Gen. 318 (1972).)[10]
This rule has been held to apply where the defendant is serving a prison sentence for one offense, while awaiting trial for another. (In re *331 Bentley (1974) 43 Cal. App.3d 988 [118 Cal. Rptr. 452].) In Bentley, the defendant was arrested for robbery. At the time he was on parole pursuant to a narcotics conviction, and a parole hold was lodged against him. Upon conviction, his sentence was ordered to be served concurrently with the narcotics sentence. The Attorney General argued that he was not entitled to section 2900.5 credit for the time in custody awaiting trial because he was then serving time on the narcotics charges. The court said: "[U]nder section 2900.5 he may receive credit for the time spent in jail awaiting the second trial although receiving credit at the same time on the narcotics conviction sentence." (Id., at p. 993.)
(2a) The question then is: How does this rule apply to the present case? In re Sutherland (1972) 6 Cal.3d 666 [100 Cal. Rptr. 129, 493 P.2d 857], holds that when a plea of guilty is set aside on motion of the defendant, any and all charges that have previously been dismissed in consideration of the plea of guilty are immediately reinstituted, and the prosecution is returned to the position it was in at the time the plea of guilty was entered, as though the plea of guilty had never been entered. In Sutherland, the court said: "At the time defendant pleaded guilty to one count, the prosecutor moved to dismiss the four remaining counts and his motion was granted. Since by granting relief we are in effect permitting defendant to withdraw his guilty plea, the ends of justice require that the status quo ante be restored by reviving the four dismissed counts." (Id., at pp. 671-672, italics added.)[11]
*332 (3) As a general rule the credit to be given pursuant to section 2900.5 runs from the date of arrest and not from the filing of the charging document. (See People v. Anderson (1975) 44 Cal. App.3d 723, 729 [118 Cal. Rptr. 918].) When charges are reinstated there is no new arrest, no new charging document. The charges relate back to the original arrest and to the original charging document.[12]
(2b) We are led then to the conclusion that when the writ of habeas corpus was granted defendant stood before the court charged with 11 counts of felony as to each of which he had, in effect, been in custody from the date of his arrest on October 1, 1969, until the date of his parole on July 14, 1972. When he pleaded guilty to four of the counts and was sentenced to serve concurrent terms therefor, he was entitled to credit for all of the time he was in custody from the date of arrest to the date he was sentenced, including the time he was in prison pursuant to the ineffectual plea of guilty.[13] Once the plea of guilty was set aside, the order dismissing nine of the offenses was just as ineffectual as the plea of guilty to the two offenses had been.

Application of Penal Code section 2900.1.
(4) Appellant contends that Penal Code section 2900.1 required the trial court to credit him with the 785 days he served in prison pursuant to his invalid plea. Section 2900.1 provides: "Where a defendant has served any portion of his sentence under a commitment based upon a judgment which judgment is subsequently declared invalid or which is modified *333 during the term of imprisonment, such time shall be credited upon any subsequent sentence he may receive upon a new commitment for the same criminal act or acts."
The Attorney General contends that the plain meaning of the words "same criminal act or acts" precludes an application of the statute. We agree.
The essential difference between section 2900.1 and 2900.5 is that 2900.5 provides a broad range of credit for time a defendant spends in custody awaiting the ultimate disposition of his case. Such time is often referred to in prisoner's jargon as "dead time." Section 2900.1, on the other hand, is of very limited application. It was enacted well before section 2900.5,[14] and has nothing to do with "dead time" as such. Section 2900.1 is only applicable where defendant has served a part of a sentence for an offense, and the judgment is declared invalid (or is modified), and the defendant is then convicted and/or sentenced again for the same offense (or an offense based on the same criminal act or acts).
The essence of our holding 2900.5 to be applicable is that while defendant was in prison serving a sentence imposed for two of the original eleven offenses, he was also in contingent custody as to the remaining nine counts, contingent in the sense that if the plea bargain failed the remaining nine counts would be revived. That is not to say that he was serving a sentence on the other nine offenses so as to bring section 2900.1 into play. Such a result would only occur as to offenses that were occasioned by the same criminal act or acts of the defendant, in which event the two sections would provide coextensive protection to the defendant. There is no evidence before us that any of the four of the original eleven counts for which defendant has been sentenced is for the same criminal act or acts as the two offenses for which defendant was imprisoned.[15]

Constitutional rights to credit for time in custody.
Defendant presents several arguments as to the application of constitutional provisions to his case.
*334 (5) First, defendant argues that it would violate the equal protection clause of the Fourteenth Amendment to the United States Constitution and article I, section 7, of the California Constitution, if he is denied credit merely because he was held in prison rather than a county jail.
The argument is apparently based on a concern that Penal Code section 2900.5, as it was written at the time defendant was sentenced on June 7, 1973, and not as it is presently worded, would be held to apply. At that time the wording did not include credit for time in prison.
We do not so hold. As pointed out in footnote 9, supra, section 2900.5 is completely retroactive. (In re Kapperman, supra, 11 Cal.3d 542, 545.) Penal Code section 2900.5 now specifically provides credit for any time defendant was in prison toward any sentence he receives thereafter, provided the custody in prison is attributable to the offenses for which he is subsequently sentenced.
The same result would have followed had the statute not been amended. In the case of In re Jordan (1975) 50 Cal. App.3d 155 [123 Cal. Rptr. 268], the court held that despite the narrow language of the statute (as it was then written) the defendant was entitled to credit for the two years he was in federal custody before the federal charges were dismissed and he was returned to a California detainer.
Also in People v. Cowsar (1974) 40 Cal. App.3d 578, 581 [115 Cal. Rptr. 160], the court held defendant was entitled to credit for time he was in the hospital to determine his sanity, even though the statute did not at that time so provide.
Similarly the court held in In re Watson (1977) 19 Cal.3d 646 [139 Cal. Rptr. 609, 566 P.2d 243], that defendant was entitled to credit for the time he was in custody of Texas authorities resisting extradition to California.
(6) Second, defendant contends that the due process clause of the Fourteenth Amendment to the United States Constitution and article I, sections 7 and 15, of the California Constitution mandate credit for time in custody prior to sentence.
Defendant contends that apart from statutory provisions requiring credit for time in custody, a denial of credit for the time he served in prison pursuant to the dismissed charges will result in a grave miscarriage *335 of justice, and violate traditional concepts of fair play which underline our notion of due process. Appellant asserts that to deny him credit for time served will, in effect, "chill" the exercise of his right to seek redress from an invalid conviction.
Appellant's contention is well taken. In Patton v. State of North Carolina (4th Cir.1967) 381 F.2d 636, the defendant was convicted of armed robbery and five years later he was retried after his first conviction was set aside. The defendant was convicted a second time, but was not given credit for the time served pursuant to the first conviction. The court in holding that the defendant was entitled to credit for time served stated: "The principle of fair dealing which impels judges in passing sentence to take into account the time a defendant was deprived of his liberty while awaiting trial, [citation], insists even more inexorably that he shall not be finessed out of credit for time he was forced to serve under an invalid sentence. The trial and conviction may be voided on appeal, but the time illegally exacted by the unconstitutional sentence is an irreversible fact.... [¶] The risk of a denial of credit ... on retrial may prevent defendants who have been unconstitutionally convicted from attempting to seek redress." (Id., at pp. 638-639, italics added.)
In North Carolina v. Pearce (1969) 395 U.S. 711 [23 L.Ed.2d 656, 89 S.Ct. 2072], the United States Supreme Court held that if a conviction is overturned any time served pursuant to the first conviction must be credited in imposing sentence upon a new conviction for the same offense. (Id., at pp. 718-719 [23 L.Ed.2d at p. 665].)
While both Patton and Pearce involve a second conviction for the same offense as the first, the same traditional notions of fair play which underline the due process concept as stated in Patton compel the conclusion that where defendant is charged with a number of offenses, and he enters into a plea bargain that is set aside for reasons of unconstitutional process employed in taking the plea,[16] and then enters into a second plea bargain involving the same charges, he is entitled to credit for time spent in prison pursuant to the first plea bargain, even though the precise counts to which he pleaded guilty in each bargain were not the same.
*336 (7) Lastly, defendant contends that he has been denied due process because the terms of the second plea bargain were harsher than the first.
This argument is not well taken. In North Carolina v. Pearce, supra, 395 U.S. 711, the Supreme Court held "neither the double jeopardy provision nor the Equal Protection Clause imposes an absolute bar to a more severe sentence upon reconviction." (Id., at p. 723 [23 L.Ed.2d at p. 668].) However, the Supreme Court did hold that due process of law "requires that vindictiveness against a defendant for having successfully attacked his first conviction must play no part in the sentence he receives after a new trial." (Id., at p. 725 [23 L.Ed.2d at p. 669].)
The California Supreme Court has held that the California Constitution's guarantee against double jeopardy precludes the imposition of a more severe sentence upon retrial. (People v. Henderson (1963) 60 Cal.2d 482, 497 [35 Cal. Rptr. 77, 386 P.2d 677]; see also People v. Serrato (1973) 9 Cal.3d 753, 761-762 [109 Cal. Rptr. 65, 512 P.2d 289]; People v. Hood (1969) 1 Cal.3d 444, 459 [82 Cal. Rptr. 618, 462 P.2d 370]; People v. Ali (1967) 66 Cal.2d 277, 281-282 [57 Cal. Rptr. 348, 424 P.2d 932].) "The rule is otherwise when a trial court pronounces an unauthorized sentence. Such a sentence is subject to being set aside judicially and is no bar to the imposition of a proper judgment thereafter, even though it is more severe than the original unauthorized pronouncement." (People v. Serrato, supra, at p. 764.) "An analogous situation is found in the cases where a conviction based upon a negotiated guilty plea is set aside because of the trial court's failure to obtain constitutionally required waivers." (Id., at p. 765.)
In People v. Hughes (1975) 50 Cal. App.3d 749, 754 [123 Cal. Rptr. 767], the court held there is no merit in the contention that where a defendant has rejected a plea bargain he cannot be given a disposition that is harsher than the offered bargain.

Conclusion.
Pursuant to Penal Code section 2900.5 and constitutional provisions which guarantee an accused person due process of law, we hold that defendant, Irving Schuler, is entitled to credit for an additional 785 days as to each of the following offenses: Two counts of robbery in the first degree (Pen. Code, § 211) as alleged in counts two and three of information No. 45857; one count of burglary in the second degree (Pen. Code, § 459) as alleged in information No. 46169; and one count of *337 assault with intent to commit murder (Pen. Code, § 217) as alleged in information No. 47259.[17]
We therefore order that the cause be remanded to the trial court with direction to amend the judgments in each of the above cases in conformity with this opinion.
This opinion does not in any way affect the judgment imposed in information No. 54911.
Taylor, P.J., and Kane, J., concurred.
NOTES
[*]   Assigned by the Chairperson of the Judicial Council.
[1]  The issue is appropriately raised on a direct appeal. (People v. Brasley (1974) 41 Cal. App.3d 311, 314 [115 Cal. Rptr. 910].)
[2]  Plea bargains have been approved by the California Supreme Court provided the bargain is fully disclosed in open court and made a part of the record. (People v. West (1970) 3 Cal.3d 595 [91 Cal. Rptr. 385, 477 P.2d 409].)
[3]  The offenses to which defendant entered a plea of guilty in this plea bargain included: Count one of information No. 45857, to-wit, robbery in the first degree (Pen. Code, § 211), as to this charge an allegation that defendant was armed with and used a firearm (Pen. Code, § 12022.5) was stricken; and robbery in the first degree as alleged in information No. 46414.
[4]  The offenses which were dismissed were: Three counts of robbery as alleged in counts two, three and four of information No. 45857 (arming/use clauses as to each count were stricken); three counts of credit card forgery (Pen. Code, § 484f) as alleged in counts one, two and three of information No. 46120; burglary (Pen. Code, § 459) as alleged in information No. 46167; burglary as alleged in information No. 46169; and assault with intent to commit murder (Pen. Code, § 217) as alleged in information No. 47259 (an arming/use clause as to this offense was stricken).
[5]  Defendant filed an appeal from this conviction. The conviction has been affirmed and is now final. (People v. Schuler (May 30, 1974) 1 Crim. 12400.)
[6]  In the second plea bargain, defendant pleaded guilty to two counts of robbery in the first degree (Pen. Code, § 211) as alleged in counts two and three of information No. 45857; burglary in the second degree (Pen. Code, § 459) as alleged in information No. 46169; and assault with intent to commit murder (Pen. Code, § 217) as alleged in information No. 47259. As to this latter charge, an allegation that defendant was armed with and used a firearm (Pen. Code, § 12022.5) was dismissed.
[7]  When defendant was sentenced on June 7, 1973, the sentences for counts two and three of information No. 45857 were made to run consecutively with each other. Defendant filed a second petition for habeas corpus, as a result of which the Court of Appeal in an unpublished opinion ordered the sentences to be served concurrently as contemplated by the second plea bargain or that the convictions again be set aside. (In re Schuler (Jan. 9, 1976) 1 Crim. 14741.) As a result, defendant was resentenced on May 24, 1976, to serve concurrent sentences as to all offenses.
[8]  As to counts two and three of information No. 45857, defendant was given credit from October 1, 1969, the date of his arrest to May 20, 1970, the date these two counts were dismissed as part of the first plea bargain, and from April 20, 1973, the date the charges were reinstated to June 7, 1973, the date when defendant was sent to prison after the second plea bargain. Defendant was given credit for the same periods of time as to information No. 46169. As to information No. 47259, defendant was given credit from February 13, 1970, the date the charges contained therein were first brought against defendant, to May 23, 1970, the date they were dismissed as part of the first plea bargain, and from April 20, 1973, the date they were revived, to June 7, 1973, the date of sentence.
[9]  Section 2900.5 was added to the Penal Code in 1971, after the date of the offenses here involved. As originally written the section was to be applicable only as to persons delivered to the custody of the Director of the Department of Corrections on or after January 1, 1972. (Stats. 1971, ch. 1732, p. 3686.) This limitation has been held to be unconstitutional as a classification not reasonably related to a legitimate public purpose. (In re Kapperman (1974) 11 Cal.3d 542, 545 [114 Cal. Rptr. 97, 522 P.2d 657].) The statute was amended in 1976 to eliminate this restriction, and to extend the protection of the statute. (Stats. 1976, ch. 1045, § 2.) Defendant is entitled to the benefit of the statute as it is now written. (In re Kapperman, supra, at p. 545; see also People v. Rossi (1976) 18 Cal.3d 295, 299 [134 Cal. Rptr. 64, 555 P.2d 1313]; In re Estrada (1965) 63 Cal.2d 740, 748 [48 Cal. Rptr. 172, 408 P.2d 948].)
[10]  Compare Cerda v. Superior Court (1974) 42 Cal. App.3d 491, 495 [116 Cal. Rptr. 896], which holds that where the defendant is given consecutive sentences he must be regarded as undergoing a single continuous term of confinement rather than a series of distinct independent terms; in such case any credit to be given him pursuant to section 2900.5 must be computed against the total term.
[11]  The procedure adopted by Sutherland is the same as the statutory procedure provided for in the case of a conditional plea entered pursuant to Penal Code section 1192.5. Under section 1192.5, at the time defendant enters a plea of guilty he may specify the punishment to be imposed. If he does so, and the plea is accepted by the prosecutor and approved by the court, the defendant cannot be given any sentence greater than that so specified. However, the court must inform the defendant that the plea is conditional upon final approval by the court on the day of sentence. If at that time the court decides to impose a greater sentence, the defendant must first be permitted to withdraw his plea of guilty. People v. Johnson (1974) 10 Cal.3d 868 [112 Cal. Rptr. 556, 519 P.2d 604], holds that where charges are dismissed in consideration of a plea of guilty, and the plea is set aside pursuant to section 1192.5, all original charges are revived. Surely in such a case a defendant who has been in custody would be entitled to credit for the time a charge is conditionally dismissed, if he is later sentenced on that charge.

An analogous procedure may also be found in People v. Cheffen (1969) 2 Cal. App.3d 638, 642-643 [82 Cal. Rptr. 658], where the court holds that to prevent double punishment as proscribed by Penal Code section 654 the court should impose sentence on all offenses coming within the section, and then stay all but the most serious. Then, in the event that the most serious is reversed or set aside, the sentence for one of the others may be carried out. In such a case the defendant must be given credit for time in custody on the most serious offense.
[12]  Compare Burris v. Superior Court (1974) 43 Cal. App.3d 530, 539 [117 Cal. Rptr. 898], where a defendant was charged in the same complaint with both felony and misdemeanor counts. The magistrate erroneously accepted a plea of guilty to the misdemeanor and sentenced defendant to the county jail. The judgment was set aside on grounds that the magistrate had no authority to sentence a defendant for a misdemeanor joined with a felony, but could only determine if there was cause to hold the misdemeanor to the superior court for trial. However, it was held that defendant was entitled to credit for the time he served thereon toward a later conviction for the felony. This decision was made without any discussion as to whether or not the acts constituting the misdemeanor were attributable to the same conduct as the felony, a conclusion which does not necessarily follow as a matter of course. (See also People v. Ayala (1973) 34 Cal. App.3d 360 [109 Cal. Rptr. 193].)
[13]  In Agata, Time Served Under a Reversed Sentence or Conviction  Proposal and a Basis for Decision (1963) 25-26 Mont.L.Rev. 3, 44, the author observes: "[W]hen there has been a conviction on only one charge, but it was in satisfaction of the other charges ... the defendant should be deemed to have been serving time for all of the offenses satisfied by the conviction. In the absence of error, this would have been the result, and the new sentence clearly is imposed in lieu of the reversed sentence and as a consequence of the reversal."
[14]  Section 2900.5 was first enacted in 1971. Section 2900.1 was first enacted in 1949.
[15]  Our holding that section 2900.1 is inapplicable to the present case is unlikely to have any future importance. The wide-ranging protection of Penal Code section 2900.5 now includes credit for time in custody previously only provided by section 2900.1.
[16]  In the present case, the pleas of guilty to the two counts of robbery were set aside on habeas corpus because defendant was not advised of the constitutional rights which are surrendered on a plea of guilty.
[17]  We decline adoption of the procedure suggested in In re Handsome (1977) 72 Cal. App.3d 657 [138 Cal. Rptr. 400]. In Handsome, the court held defendant could not demand credit for time served while retaining other benefits of the plea bargain. Unlike the Handsome case, it does not appear that the bargain in the present case contemplated any waiver of credit for time in custody. From the record it would appear that the trial court intended to give defendant credit for such time as he was legally entitled.

In fact, the trial judge stated he believed the Adult Authority was obliged to "take into consideration the time ... that he served in State Prison on the actions which were dismissed," and advised the defendant that in the event he was not given such credit he had the right of habeas corpus "against the board for the time to which you're entitled."
