VirtualBox

Ignore:
Timestamp:
Jul 7, 2018 7:06:09 PM (7 years ago)
Author:
vboxsync
Message:

Runtime/RTJson: Some error checking addendums to r123506 (bugref:9188)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/misc/json.cpp

    r72954 r72955  
    167167    /** The next token in the input stream (used for peeking). */
    168168    PRTJSONTOKEN            pTokenNext;
     169    /** The tokenizer error state. */
     170    int                     rcTok;
    169171} RTJSONTOKENIZER;
    170172/** Pointer to a JSON tokenizer. */
     
    705707    }
    706708
     709    if (RT_FAILURE(rc))
     710        pTokenizer->rcTok = rc;
     711
    707712    return rc;
    708713}
     
    728733    pTokenizer->pTokenCurr   = &pTokenizer->Token1;
    729734    pTokenizer->pTokenNext   = &pTokenizer->Token2;
     735    pTokenizer->rcTok        = VINF_SUCCESS;
    730736
    731737    RT_ZERO(pTokenizer->achBuf);
     
    763769DECLINLINE(int) rtJsonTokenizerGetToken(PRTJSONTOKENIZER pTokenizer, PRTJSONTOKEN *ppToken)
    764770{
    765     *ppToken = pTokenizer->pTokenCurr;
    766     return VINF_SUCCESS;
     771    if (RT_SUCCESS(pTokenizer->rcTok))
     772    {
     773        *ppToken = pTokenizer->pTokenCurr;
     774        return VINF_SUCCESS;
     775    }
     776
     777    return pTokenizer->rcTok;
    767778}
    768779
     
    795806    PRTJSONTOKEN pToken = NULL;
    796807    int rc = rtJsonTokenizerGetToken(pTokenizer, &pToken);
    797     AssertRC(rc);
    798 
    799     if (pToken->enmClass == enmClass)
    800     {
    801         rtJsonTokenizerConsume(pTokenizer);
    802         return true;
     808    if (RT_SUCCESS(rc))
     809    {
     810        if (pToken->enmClass == enmClass)
     811        {
     812            rtJsonTokenizerConsume(pTokenizer);
     813            return true;
     814        }
    803815    }
    804816
     
    958970           && pToken->enmClass == RTJSONTOKENCLASS_STRING)
    959971    {
    960         char *pszName = pToken->Class.String.pszStr;
     972        char *pszName = pToken->Class.String.pszStr; /* We can consume this string as it was allocated. */
    961973
    962974        rtJsonTokenizerConsume(pTokenizer);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette