VirtualBox

Changeset 46908 in vbox


Ignore:
Timestamp:
Jul 2, 2013 1:28:36 PM (12 years ago)
Author:
vboxsync
Message:

server.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/xpcom/server.cpp

    r45518 r46908  
    880880    nsresult rc;
    881881
     882    char szLogFile[RTPATH_MAX];
    882883    if (!pszLogFile)
    883884    {
    884         char szLogFile[RTPATH_MAX] = "";
    885885        vrc = com::GetVBoxUserHomeDirectory(szLogFile, sizeof(szLogFile));
    886         if (vrc == VERR_ACCESS_DENIED)
    887             return RTMsgErrorExit(RTEXITCODE_FAILURE, "failed to open global settings directory '%s'", szLogFile);
    888886        if (RT_SUCCESS(vrc))
    889887            vrc = RTPathAppend(szLogFile, sizeof(szLogFile), "VBoxSVC.log");
    890         if (RT_SUCCESS(vrc))
    891             pszLogFile = RTStrDup(szLogFile);
    892         if (RT_FAILURE(vrc))
    893             return RTMsgErrorExit(RTEXITCODE_FAILURE, "failed to determine release log file (%Rrc)", vrc);
    894     }
     888    }
     889    else
     890    {
     891        if (!RTStrPrintf(szLogFile, sizeof(szLogFile), "%s", pszLogFile))
     892            vrc = VERR_NO_MEMORY;
     893    }
     894    if (RT_FAILURE(vrc))
     895        return RTMsgErrorExit(RTEXITCODE_FAILURE, "failed to create logging file name, rc=%Rrc", vrc);
     896
    895897    char szError[RTPATH_MAX + 128];
    896     vrc = com::VBoxLogRelCreate("XPCOM Server", pszLogFile,
     898    vrc = com::VBoxLogRelCreate("XPCOM Server", szLogFile,
    897899                                RTLOGFLAGS_PREFIX_THREAD | RTLOGFLAGS_PREFIX_TIME_PROG,
    898900                                "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