VirtualBox

Ignore:
Timestamp:
Jun 2, 2021 9:50:28 AM (4 years ago)
Author:
vboxsync
Message:

ValKit/AudioTest: You do not need to RTStrDup ValueUnion.psz, the string will be there till we return. bugref:10008

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/utils/audio/vkat.cpp

    r89459 r89460  
    16401640     * Parse options and process arguments.
    16411641     */
    1642     char     *pszSetA = NULL;
    1643     char     *pszSetB = NULL;
    1644     unsigned iTestSet = 0;
     1642    const char *apszSets[2] = { NULL, NULL };
     1643    unsigned    iTestSet    = 0;
    16451644
    16461645    int           rc;
     
    16541653
    16551654            case VINF_GETOPT_NOT_OPTION:
    1656             {
    1657                 char **ppszSet = iTestSet == 0 ? &pszSetA : &pszSetB;
    1658 
    16591655                if (iTestSet == 0)
    16601656                    RTTestBanner(g_hTest);
    1661 
    1662                 *ppszSet = RTStrDup(ValueUnion.psz);
    1663                 AssertPtrReturn(*ppszSet, RTEXITCODE_FAILURE);
    1664 
    1665                 iTestSet++;
    1666                 break;
    1667             }
     1657                if (iTestSet >= RT_ELEMENTS(apszSets))
     1658                    return RTMsgErrorExitFailure("Only two test sets can be verified at one time");
     1659                apszSets[iTestSet++] = ValueUnion.psz;
     1660                break;
    16681661
    16691662            AUDIO_TEST_COMMON_OPTION_CASES(ValueUnion);
     
    16761669    if (!iTestSet)
    16771670        return RTMsgErrorExitFailure("At least one test set must be specified");
    1678 
    1679     if (iTestSet > 2)
    1680         return RTMsgErrorExitFailure("Only two test sets can be verified at one time");
    16811671
    16821672    /*
     
    16841674     * for test set B.
    16851675     */
     1676    char szDirCur[RTPATH_MAX];
    16861677    if (iTestSet == 1)
    16871678    {
    1688         char szDirCur[RTPATH_MAX];
    16891679        rc = RTPathGetCurrent(szDirCur, sizeof(szDirCur));
    16901680        if (RT_SUCCESS(rc))
    1691         {
    1692             Assert(pszSetB == NULL);
    1693             pszSetB = RTStrDup(szDirCur);
    1694             AssertPtrReturn(pszSetB, RTEXITCODE_FAILURE);
    1695         }
     1681            apszSets[1] = szDirCur;
    16961682        else
    16971683            RTTestFailed(g_hTest, "Failed to retrieve current directory: %Rrc", rc);
     
    16991685
    17001686    if (RT_SUCCESS(rc))
    1701         rc = audioVerifyOne(pszSetA, pszSetB);
    1702 
    1703     RTStrFree(pszSetA);
    1704     RTStrFree(pszSetB);
     1687        audioVerifyOne(apszSets[0], apszSets[1]);
    17051688
    17061689    /*
     
    22732256        {
    22742257            case VKAT_SELFTEST_OPT_ATS_HOST:
    2275                 pszAtsAddr = RTStrDup(ValueUnion.psz);
     2258                pszAtsAddr = ValueUnion.psz;
    22762259                break;
    22772260
     
    22942277
    22952278    audioTestDoSelftest(pDrvReg, pszAtsAddr);
    2296 
    2297     RTStrFree(pszAtsAddr);
    22982279
    22992280    /*
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