VirtualBox

Changeset 33320 in vbox


Ignore:
Timestamp:
Oct 21, 2010 5:09:15 PM (14 years ago)
Author:
vboxsync
Message:

Main-OVF: memory leaks

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

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

    r33289 r33320  
    17361736            // Now fully build a valid ovf document in memory
    17371737            buildXML(writeLock, doc, stack, pTask->locInfo.strPath, pTask->enFormat);
     1738            /* Extract the path */
     1739            Utf8Str strOvfFile = Utf8Str(pTask->locInfo.strPath).stripExt().append(".ovf");
    17381740            // Create a memory buffer containing the XML. */
    1739             void *pvBuf;
     1741            void *pvBuf = 0;
    17401742            size_t cbSize;
    17411743            xml::XmlMemWriter writer;
    17421744            writer.write(doc, &pvBuf, &cbSize);
    1743             /* Extract the path */
    1744             Utf8Str tmpPath = pTask->locInfo.strPath;
    1745             /* Remove the extension and add ovf. */
    1746             tmpPath.stripExt()
    1747                 .append(".ovf");
     1745            if (RT_UNLIKELY(!pvBuf))
     1746                throw setError(VBOX_E_FILE_ERROR,
     1747                               tr("Could not create OVF file '%s'"),
     1748                               strOvfFile.c_str());
    17481749            /* Write the ovf file to disk. */
    1749             vrc = Sha1WriteBuf(tmpPath.c_str(), pvBuf, cbSize, pCallbacks, pStorage);
     1750            vrc = Sha1WriteBuf(strOvfFile.c_str(), pvBuf, cbSize, pCallbacks, pStorage);
     1751            RTMemFree(pvBuf);
    17501752            if (RT_FAILURE(vrc))
    17511753                throw setError(VBOX_E_FILE_ERROR,
    17521754                               tr("Could not create OVF file '%s' (%Rrc)"),
    1753                                tmpPath.c_str(), vrc);
    1754             fileList.push_back(STRPAIR(tmpPath, pStorage->strDigest));
     1755                               strOvfFile.c_str(), vrc);
     1756            fileList.push_back(STRPAIR(strOvfFile, pStorage->strDigest));
    17551757        }
    17561758
     
    18401842            // Create & write the manifest file
    18411843            Utf8Str strMfFilePath = Utf8Str(pTask->locInfo.strPath).stripExt().append(".mf");
    1842             Utf8Str strMfFileName = Utf8Str(strMfFilePath)
    1843                 .stripPath();
     1844            Utf8Str strMfFileName = Utf8Str(strMfFilePath).stripPath();
    18441845            pTask->pProgress->SetNextOperation(BstrFmt(tr("Creating manifest file '%s'"), strMfFileName.c_str()).raw(),
    18451846                                               m->ulWeightForManifestOperation);     // operation's weight, as set up with the IProgress originally);
  • trunk/src/VBox/Main/ApplianceImplImport.cpp

    r33294 r33320  
    24902490    if (FAILED(rc)) throw rc;
    24912491
    2492     // return the new machine as an IMachine
    2493     IMachine *p;
    2494     rc = pNewMachine.queryInterfaceTo(&p);
    2495     if (FAILED(rc)) throw rc;
    2496     pReturnNewMachine = p;
     2492    pReturnNewMachine = ComPtr<IMachine>(pNewMachine);
    24972493
    24982494    // and register it
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