VirtualBox

Changeset 86400 in vbox for trunk


Ignore:
Timestamp:
Oct 1, 2020 7:55:24 PM (4 years ago)
Author:
vboxsync
Message:

IPRT/tstUtf8: Fixed a bunch of leaks in the tests. bugref:9841

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/testcase/tstUtf8.cpp

    r83886 r86400  
    9999        if (rc == VINF_SUCCESS)
    100100        {
     101            RTStrFree(pszUtf8);
    101102            rc = RTStrCurrentCPToUtf8(&pszUtf8, pszCurrent);
    102103            if (rc == VINF_SUCCESS)
     
    105106                RTTestFailed(hTest, "%d: The third part of random UTF-16 -> UTF-8 -> Current -> UTF-8 failed with return value %Rrc.",
    106107                             __LINE__, rc);
    107         }
    108         else if (rc == VERR_NO_TRANSLATION)
    109             RTTestPassed(hTest, "The second part of random UTF-16 -> UTF-8 -> Current -> UTF-8 returned VERR_NO_TRANSLATION.  This is probably as it should be.\n");
    110         else if (rc == VWRN_NO_TRANSLATION)
    111             RTTestPassed(hTest, "The second part of random UTF-16 -> UTF-8 -> Current -> UTF-8 returned VWRN_NO_TRANSLATION.  This is probably as it should be.\n");
     108            if (RT_SUCCESS(rc))
     109                RTStrFree(pszUtf8);
     110            RTStrFree(pszCurrent);
     111        }
    112112        else
    113             RTTestFailed(hTest, "%d: The second part of random UTF-16 -> UTF-8 -> Current -> UTF-8 failed with return value %Rrc.",
    114                          __LINE__, rc);
     113        {
     114            if (rc == VERR_NO_TRANSLATION)
     115                RTTestPassed(hTest, "The second part of random UTF-16 -> UTF-8 -> Current -> UTF-8 returned VERR_NO_TRANSLATION.  This is probably as it should be.\n");
     116            else if (rc == VWRN_NO_TRANSLATION)
     117                RTTestPassed(hTest, "The second part of random UTF-16 -> UTF-8 -> Current -> UTF-8 returned VWRN_NO_TRANSLATION.  This is probably as it should be.\n");
     118            else
     119                RTTestFailed(hTest, "%d: The second part of random UTF-16 -> UTF-8 -> Current -> UTF-8 failed with return value %Rrc.",
     120                             __LINE__, rc);
     121            if (RT_SUCCESS(rc))
     122                RTStrFree(pszCurrent);
     123            RTStrFree(pszUtf8);
     124        }
    115125    }
    116126    else
    117127        RTTestFailed(hTest, "%d: The first part of random UTF-16 -> UTF-8 -> Current -> UTF-8 failed with return value %Rrc.",
    118128                     __LINE__, rc);
     129    RTMemFree(pwszRand);
    119130
    120131    /*
     
    142153                RTTestPrintf(hTest, RTTESTLVL_FAILURE, "First differing character is at position %d and has the value %x.\n", i, pwsz[i]);
    143154            }
     155            RTUtf16Free(pwsz);
    144156        }
    145157        else
    146158            RTTestFailed(hTest, "%d: The second part of random UTF-16 -> UTF-8 -> UTF-16 failed with return value %Rrc.",
    147159                         __LINE__, rc);
     160        RTStrFree(pszUtf8);
    148161    }
    149162    else
    150163        RTTestFailed(hTest, "%d: The first part of random UTF-16 -> UTF-8 -> UTF-16 failed with return value %Rrc.",
    151164                     __LINE__, rc);
     165    RTMemFree(pwszRand);
    152166
    153167    /*
     
    178192                RTTestPrintf(hTest, RTTESTLVL_FAILURE, "First differing character is at position %d and has the value %x.\n", i, pwsz[i]);
    179193            }
     194            RTUtf16Free(pwsz);
    180195        }
    181196        else
     
    184199    else
    185200        RTTestFailed(hTest, "%d: The first part of random UTF-16 -> fixed length UTF-8 -> UTF-16 failed with return value %Rrc.\n", __LINE__, rc);
     201    RTMemFree(pwszRand);
    186202
    187203    /*
     
    215231        else
    216232            RTTestFailed(hTest, "%d: The second part of random UTF-16 -> UTF-8 -> fixed length UTF-16 failed with return value %Rrc.\n", __LINE__, rc);
     233        RTStrFree(pszUtf8);
    217234    }
    218235    else
    219236        RTTestFailed(hTest, "%d: The first part of random UTF-16 -> UTF-8 -> fixed length UTF-16 failed with return value %Rrc.\n",
    220237                     __LINE__, rc);
     238    RTMemFree(pwszRand);
     239
    221240    pwszRand = (PRTUTF16)RTMemAlloc(31 * sizeof(*pwsz));
    222241    for (int i = 0; i < 30; i++)
     
    230249        RTTestFailed(hTest, "%d: Random UTF-16 -> fixed length UTF-8 with too small buffer returned value %d instead of VERR_BUFFER_OVERFLOW.\n",
    231250                     __LINE__, rc);
     251    RTMemFree(pwszRand);
    232252
    233253    /*
     
    249269            RTTestFailed(hTest, "%d: The second part of random UTF-16 -> UTF-8 -> fixed length UTF-16 with too short buffer returned value %Rrc instead of VERR_BUFFER_OVERFLOW.\n",
    250270                         __LINE__, rc);
     271        RTStrFree(pszUtf8);
    251272    }
    252273    else
    253274        RTTestFailed(hTest, "%d:The first part of random UTF-16 -> UTF-8 -> fixed length UTF-16 failed with return value %Rrc.\n",
    254275                     __LINE__, rc);
    255 
     276    RTMemFree(pwszRand);
    256277
    257278    RTTestSubDone(hTest);
     
    495516
    496517        /** @todo RTCpsToUtf8 or something. */
     518        RTUniFree(paCps);
    497519    }
    498520    else
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