VirtualBox

Changeset 103438 in vbox


Ignore:
Timestamp:
Feb 19, 2024 1:41:38 PM (9 months ago)
Author:
vboxsync
Message:

IPRT/dbgmod: Simplified and restored old alloca errora handling behavior in rtDbgModOpenDebugInfoExternalToImageCallback. bugref:3409

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/dbg/dbgmod.cpp

    r103285 r103438  
    597597         * the latter can be normalized or using a different name (e.g. 'nt').
    598598         */
    599         const char *pszExt = NULL;
     599        const char *pszExtSuff = NULL;
     600        size_t      cchExtSuff = 0;
    600601        if (pDbgInfo->enmType == RTLDRDBGINFOTYPE_CODEVIEW_DBG)
    601             pszExt = ".dbg";
     602            pszExtSuff = ".dbg", cchExtSuff = sizeof(".dbg") - 1;
    602603        else if (   pDbgInfo->enmType == RTLDRDBGINFOTYPE_CODEVIEW_PDB20
    603604                 || pDbgInfo->enmType == RTLDRDBGINFOTYPE_CODEVIEW_PDB70)
    604             pszExt = ".pdb";
    605         if (pszExt)
     605            pszExtSuff = ".pdb", cchExtSuff = sizeof(".pdb") - 1;
     606        if (pszExtSuff)
    606607        {
    607608            const char * const pszName = pDbgMod->pszImgFile
     
    610611            if (pszName)
    611612            {
    612                 size_t const cchName       = strlen(pszName);
    613                 size_t const cchExtFileBuf = cchName + strlen(pszExt) + 1;
    614 
    615                 char *pszExtFileBuf = (char *)alloca(cchExtFileBuf);
    616                 AssertPtrReturn(pszExtFileBuf, VERR_NO_MEMORY);
    617 
    618                 memcpy(pszExtFileBuf, pszName, cchName + 1);
    619                 RTPathStripSuffix(pszExtFileBuf);
    620                 int rc2 = RTStrCat(pszExtFileBuf, cchExtFileBuf, pszExt);
    621                 AssertRCReturn(rc2, rc2);
    622 
    623                 pszExtFile = pszExtFileBuf;
     613                const char * const  pszOldSuff    = RTPathSuffix(pszName);
     614                size_t const        cchName       = pszOldSuff ? (size_t)(pszOldSuff - pszName) : strlen(pszName);
     615                char * const        pszExtFileBuf = (char *)alloca(cchName + cchExtSuff + 1);
     616                if (pszExtFileBuf)
     617                {
     618                    memcpy(mempcpy(pszExtFileBuf, pszName, cchName), pszExtSuff, cchExtSuff + 1);
     619                    pszExtFile = pszExtFileBuf;
     620                }
    624621            }
    625622        }
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