VirtualBox

Changeset 66080 in vbox for trunk


Ignore:
Timestamp:
Mar 14, 2017 10:42:55 AM (8 years ago)
Author:
vboxsync
Message:

iprt/manifest2.cpp: Use RT_FLEXIBLE_ARRAY and RT_FLEXIBLE_ARRAY_NESTED.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/checksum/manifest2.cpp

    r62564 r66080  
    6565    bool                fVisited;
    6666    /** The normalized property name that StrCore::pszString points at. */
    67     char                szName[1];
     67    char                szName[RT_FLEXIBLE_ARRAY];
    6868} RTMANIFESTATTR;
    6969/** Pointer to a manifest attribute. */
     
    8686    bool                fVisited;
    8787    /** The normalized entry name that StrCore::pszString points at. */
    88     char                szName[1];
     88    char                szName[RT_FLEXIBLE_ARRAY_NESTED];
    8989} RTMANIFESTENTRY;
    9090/** Pointer to a manifest entry. */
     
    193193    AssertPtr(phManifest);
    194194
    195     RTMANIFESTINT *pThis = (RTMANIFESTINT *)RTMemAlloc(sizeof(*pThis));
     195    RTMANIFESTINT *pThis = (RTMANIFESTINT *)RTMemAlloc(RT_UOFFSETOF(RTMANIFESTINT, SelfEntry.szName[1]));
    196196    if (!pThis)
    197197        return VERR_NO_MEMORY;
     
    698698    else
    699699    {
    700         size_t         cbName = strlen(pszAttr) + 1;
    701         pAttr = (PRTMANIFESTATTR)RTMemAllocVar(RT_OFFSETOF(RTMANIFESTATTR, szName[cbName]));
     700        size_t const cbName = strlen(pszAttr) + 1;
     701        pAttr = (PRTMANIFESTATTR)RTMemAllocVar(RT_UOFFSETOF(RTMANIFESTATTR, szName[cbName]));
    702702        if (!pAttr)
    703703        {
     
    10651065    if (rc == VERR_NOT_FOUND)
    10661066    {
    1067         pEntry = (PRTMANIFESTENTRY)RTMemAlloc(RT_OFFSETOF(RTMANIFESTENTRY, szName[cchEntry + 1]));
     1067        pEntry = (PRTMANIFESTENTRY)RTMemAlloc(RT_UOFFSETOF(RTMANIFESTENTRY, szName[cchEntry + 1]));
    10681068        if (!pEntry)
    10691069            return VERR_NO_MEMORY;
     
    11911191    if (rc == VERR_NOT_FOUND)
    11921192    {
    1193         pEntry = (PRTMANIFESTENTRY)RTMemAlloc(RT_OFFSETOF(RTMANIFESTENTRY, szName[cchEntry + 1]));
     1193        pEntry = (PRTMANIFESTENTRY)RTMemAlloc(RT_UOFFSETOF(RTMANIFESTENTRY, szName[cchEntry + 1]));
    11941194        if (pEntry)
    11951195        {
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