VirtualBox

Changeset 86778 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Oct 31, 2020 1:42:13 AM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
141176
Message:

IPRT/rest: bugref:9167 - don't try to deserialize null as if it were
an object. Check for it explicitly and punt. This avoids an
assertion in a debug build. While here add a few more explicit
isNull() checks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/rest/RTCRestStringMapBase.cpp

    r82968 r86778  
    119119int RTCRestStringMapBase::deserializeFromJson(RTCRestJsonCursor const &a_rCursor) RT_NOEXCEPT
    120120{
     121    if (RTJsonValueGetType(a_rCursor.m_hValue) == RTJSONVALTYPE_NULL)
     122    {
     123        setNull();
     124        return VINF_SUCCESS;
     125    }
     126
    121127    /*
    122128     * Make sure the object starts out with an empty map.
     
    261267bool RTCRestStringMapBase::containsKey(const char *a_pszKey) const RT_NOEXCEPT
    262268{
     269    if (isNull())
     270        return false;
     271
    263272    return RTStrSpaceGet((PRTSTRSPACE)&m_Map, a_pszKey) != NULL;
    264273}
     
    273282bool RTCRestStringMapBase::remove(const char *a_pszKey) RT_NOEXCEPT
    274283{
     284    if (isNull())
     285        return false;
     286
    275287    MapEntry *pRemoved = (MapEntry *)RTStrSpaceRemove(&m_Map, a_pszKey);
    276288    if (pRemoved)
     
    423435RTCRestObjectBase *RTCRestStringMapBase::getWorker(const char *a_pszKey) RT_NOEXCEPT
    424436{
     437    if (isNull())
     438        return NULL;
     439
    425440    MapEntry *pHit = (MapEntry *)RTStrSpaceGet(&m_Map, a_pszKey);
    426441    if (pHit)
     
    432447RTCRestObjectBase const *RTCRestStringMapBase::getWorker(const char *a_pszKey) const RT_NOEXCEPT
    433448{
     449    if (isNull())
     450        return NULL;
     451
    434452    MapEntry const *pHit = (MapEntry const *)RTStrSpaceGet((PRTSTRSPACE)&m_Map, a_pszKey);
    435453    if (pHit)
Note: See TracChangeset for help on using the changeset viewer.

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