VirtualBox

Changeset 46907 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Jul 2, 2013 1:25:11 PM (11 years ago)
Author:
vboxsync
Message:

svcmain.cpp: Fixed memory leak, bail out when unable to build logfile name.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/win/svcmain.cpp

    r41041 r46907  
    328328    if (fRun)
    329329    {
     330        char szLogFile[RTPATH_MAX];
    330331        if (!pszLogFile)
    331332        {
    332             char szLogFile[RTPATH_MAX];
    333333            vrc = com::GetVBoxUserHomeDirectory(szLogFile, sizeof(szLogFile));
    334334            if (RT_SUCCESS(vrc))
    335335                vrc = RTPathAppend(szLogFile, sizeof(szLogFile), "VBoxSVC.log");
    336             if (RT_SUCCESS(vrc))
    337                 pszLogFile = RTStrDup(szLogFile);
    338         }
     336        }
     337        else
     338        {
     339            if (!RTStrPrintf(szLogFile, sizeof(szLogFile), "%s", pszLogFile))
     340                vrc = VERR_NO_MEMORY;
     341        }
     342        if (RT_FAILURE(vrc))
     343            return RTMsgErrorExit(RTEXITCODE_FAILURE, "failed to create logging file name, rc=%Rrc", vrc);
     344
    339345        char szError[RTPATH_MAX + 128];
    340         vrc = com::VBoxLogRelCreate("COM Server", pszLogFile,
     346        vrc = com::VBoxLogRelCreate("COM Server", szLogFile,
    341347                                    RTLOGFLAGS_PREFIX_THREAD | RTLOGFLAGS_PREFIX_TIME_PROG,
    342348                                    "all", "VBOXSVC_RELEASE_LOG",
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