VirtualBox

Changeset 104487 in vbox


Ignore:
Timestamp:
May 2, 2024 4:32:36 PM (7 months ago)
Author:
vboxsync
Message:

libs/xpcom/reflect: Some cleanups, bugref:3409

Location:
trunk/src/libs/xpcom18a4/xpcom/reflect
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/xpcom/reflect/xptcall/tests/TestXPTCInvoke.cpp

    r103458 r104487  
    10661066/***************************/
    10671067
    1068 FooImpl::FooImpl() : Name("FooImpl")
     1068FooImpl::FooImpl() : Name("FooImpl"), SomeData1(0), SomeData2(0)
    10691069{
    10701070}
     
    10861086/***************************/
    10871087
    1088 BarImpl::BarImpl() : Name("BarImpl")
     1088BarImpl::BarImpl() : Name("BarImpl"), SomeData1(0), SomeData2(0)
    10891089{
    10901090}
  • trunk/src/libs/xpcom18a4/xpcom/reflect/xptinfo/src/xptiInterfaceInfoManager.cpp

    r103458 r104487  
    356356    XPTState *state = nsnull;
    357357    XPTCursor cursor;
    358     PRInt32 flen;
    359     PRInt64 fileSize;
    360    
    361     PRBool saveFollowLinks;
    362     aFile->GetFollowLinks(&saveFollowLinks);
    363     aFile->SetFollowLinks(PR_TRUE);
    364 
    365     if(NS_FAILED(aFile->GetFileSize(&fileSize)) || !(flen = nsInt64(fileSize)))
    366     {
    367         aFile->SetFollowLinks(saveFollowLinks);
    368         return nsnull;
    369     }
    370 
    371     whole = new char[flen];
    372     if (!whole)
    373     {
    374         aFile->SetFollowLinks(saveFollowLinks);
    375         return nsnull;
    376     }
    377 
    378     // all exits from on here should be via 'goto out'
    379     int vrc = VINF_SUCCESS;
    380     size_t cbRead = 0;
    381     RTFILE hFile = NIL_RTFILE;
     358
    382359    nsCAutoString pathName;
    383360    if (NS_FAILED(aFile->GetNativePath(pathName)))
     361        return nsnull;
     362
     363
     364    // all exits from on here should be via 'goto out'
     365    RTFILE hFile = NIL_RTFILE;
     366
     367    int vrc = RTFileOpen(&hFile, pathName.get(),
     368                         RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_NONE);
     369    if (RT_FAILURE(vrc))
     370        return nsnull;
     371
     372    uint64_t cbFile = 0;
     373    vrc = RTFileQuerySize(hFile, &cbFile);
     374    if (RT_FAILURE(vrc) || cbFile >= 128 * _1M)
     375    {
     376        RTFileClose(hFile);
     377        return nsnull;
     378    }
     379
     380    whole = new char[cbFile];
     381    if (!whole)
     382    {
     383        RTFileClose(hFile);
     384        return nsnull;
     385    }
     386
     387    size_t cbRead = 0;
     388    vrc = RTFileRead(hFile, whole, cbFile, &cbRead);
     389    if(RT_FAILURE(vrc) || cbRead < cbFile)
    384390        goto out;
    385391
    386     vrc = RTFileOpen(&hFile, pathName.get(),
    387                      RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_NONE);
    388     if (RT_FAILURE(vrc))
    389         goto out;
    390 
    391     vrc = RTFileRead(hFile, whole, flen, &cbRead);
    392     if(RT_FAILURE(vrc) || cbRead < flen)
    393         goto out;
    394 
    395     if(!(state = XPT_NewXDRState(XPT_DECODE, whole, flen)))
     392    if(!(state = XPT_NewXDRState(XPT_DECODE, whole, cbFile)))
    396393    {
    397394        goto out;
     
    409406    }
    410407
    411  out:
    412     if(hFile != NIL_RTFILE)
    413         RTFileClose(hFile);
     408out:
     409    RTFileClose(hFile);
     410
    414411    if(state)
    415412        XPT_DestroyXDRState(state);
    416     if(whole)
    417         delete [] whole;
    418     aFile->SetFollowLinks(saveFollowLinks);
     413
     414    delete [] whole;
    419415    return header;
    420416}
  • trunk/src/libs/xpcom18a4/xpcom/reflect/xptinfo/src/xptiManifest.cpp

    r102457 r104487  
    307307                       PRUint32* pLength)
    308308{
    309     PRInt32 flen;
    310     PRInt64 fileSize;
    311309    char* whole = nsnull;
    312310    PRBool success = PR_FALSE;
     
    316314        return nsnull;
    317315
     316    nsCAutoString pathName;
     317    if (NS_FAILED(aFile->GetNativePath(pathName)))
     318        return nsnull;
     319
    318320#ifdef DEBUG
    319321    {
    320322        static PRBool shown = PR_FALSE;
    321323
    322         nsCAutoString path;
    323         if(!shown && NS_SUCCEEDED(aFile->GetNativePath(path)) && !path.IsEmpty())
     324        if(!shown && !pathName.IsEmpty())
    324325        {
    325             fprintf(stderr, "Type Manifest File: %s\n", path.get());
     326            fprintf(stderr, "Type Manifest File: %s\n", pathName.get());
    326327            shown = PR_TRUE;
    327328        }
     
    329330#endif
    330331
    331     if(NS_FAILED(aFile->GetFileSize(&fileSize)) || !(flen = nsInt64(fileSize)))
     332    RTFILE hFile = NIL_RTFILE;
     333    int vrc = RTFileOpen(&hFile, pathName.get(),
     334                         RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_NONE);
     335    if (RT_FAILURE(vrc))
    332336        return nsnull;
    333337
    334     whole = new char[flen];
     338    uint64_t cbFile = 0;
     339    vrc = RTFileQuerySize(hFile, &cbFile);
     340    if (RT_FAILURE(vrc) || cbFile >= 128 * _1M)
     341    {
     342        RTFileClose(hFile);
     343        return nsnull;
     344    }
     345
     346    whole = new char[cbFile];
    335347    if (!whole)
     348    {
     349        RTFileClose(hFile);
    336350        return nsnull;
    337 
    338     // All exits from on here should be via 'goto out'
    339     int vrc = VINF_SUCCESS;
     351    }
     352
    340353    size_t cbRead = 0;
    341     RTFILE hFile = NIL_RTFILE;
    342     nsCAutoString pathName;
    343     if (NS_FAILED(aFile->GetNativePath(pathName)))
    344         goto out;
    345 
    346     vrc = RTFileOpen(&hFile, pathName.get(),
    347                      RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_NONE);
    348     if (RT_FAILURE(vrc))
    349         goto out;
    350 
    351     vrc = RTFileRead(hFile, whole, flen, &cbRead);
    352     if(RT_FAILURE(vrc) || cbRead < flen)
     354    vrc = RTFileRead(hFile, whole, cbFile, &cbRead);
     355    if(RT_FAILURE(vrc) || cbRead < cbFile)
    353356        goto out;
    354357
     
    365368    }
    366369
    367     *pLength = flen;
     370    *pLength = (uint32_t)cbFile;
    368371    return whole;
    369372}
     
    705708
    706709 out:
    707     if(whole)
    708         delete [] whole;
     710    delete [] whole;
    709711
    710712    if(!succeeded)
  • trunk/src/libs/xpcom18a4/xpcom/reflect/xptinfo/src/xptiZipLoader.cpp

    r1 r104487  
    107107    if(state)
    108108        XPT_DestroyXDRState(state);
    109     if(whole)
    110         delete [] whole;
     109
     110    delete [] whole;
    111111    return header;
    112112}
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