VirtualBox

Changeset 31313 in vbox for trunk


Ignore:
Timestamp:
Aug 2, 2010 3:19:38 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
64340
Message:

Main: fix memory leak in error path

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/MachineImpl.cpp

    r31312 r31313  
    34203420                                        medium,
    34213421                                        *pMediumLockList);
    3422         if (FAILED(rc)) return rc;
    3423         rc = pMediumLockList->Lock();
    3424         if (FAILED(rc))
    3425             return setError(rc,
    3426                             tr("Could not lock medium when creating diff '%s'"),
    3427                             diff->getLocationFull().c_str());
    3428 
    3429         /* will leave the lock before the potentially lengthy operation, so
    3430          * protect with the special state */
    3431         MachineState_T oldState = mData->mMachineState;
    3432         setMachineState(MachineState_SettingUp);
    3433 
    3434         mediumLock.leave();
    3435         treeLock.leave();
    3436         alock.leave();
    3437 
    3438         rc = medium->createDiffStorage(diff,
    3439                                        MediumVariant_Standard,
    3440                                        pMediumLockList,
    3441                                        NULL /* aProgress */,
    3442                                        true /* aWait */,
    3443                                        &fNeedsSaveSettings);
    3444 
    3445         alock.enter();
    3446         treeLock.enter();
    3447         mediumLock.enter();
    3448 
    3449         setMachineState(oldState);
     3422        if (SUCCEEDED(rc))
     3423        {
     3424            rc = pMediumLockList->Lock();
     3425            if (FAILED(rc))
     3426                setError(rc,
     3427                         tr("Could not lock medium when creating diff '%s'"),
     3428                         diff->getLocationFull().c_str());
     3429            else
     3430            {
     3431                /* will leave the lock before the potentially lengthy operation, so
     3432                 * protect with the special state */
     3433                MachineState_T oldState = mData->mMachineState;
     3434                setMachineState(MachineState_SettingUp);
     3435
     3436                mediumLock.leave();
     3437                treeLock.leave();
     3438                alock.leave();
     3439
     3440                rc = medium->createDiffStorage(diff,
     3441                                               MediumVariant_Standard,
     3442                                               pMediumLockList,
     3443                                               NULL /* aProgress */,
     3444                                               true /* aWait */,
     3445                                               &fNeedsSaveSettings);
     3446
     3447                alock.enter();
     3448                treeLock.enter();
     3449                mediumLock.enter();
     3450
     3451                setMachineState(oldState);
     3452            }
     3453        }
    34503454
    34513455        /* Unlock the media and free the associated memory. */
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