VirtualBox

Changeset 29819 in vbox for trunk/src


Ignore:
Timestamp:
May 26, 2010 2:05:27 PM (15 years ago)
Author:
vboxsync
Message:

RTSha1Digest.cpp: Don't mix allocators! Also, check for allocation failure and use constants.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/checksum/RTSha1Digest.cpp

    r29778 r29819  
    9090        return VERR_INTERNAL_ERROR;
    9191
    92     *ppszDigest = (char*)RTMemAlloc(41);
    93     rc = RTSha1ToString(auchDig, *ppszDigest, 41);
    94     if (RT_FAILURE(rc))
    95         RTStrFree(*ppszDigest);
     92    char *pszDigest;
     93    rc = RTStrAllocEx(&pszDigest, RTSHA1_DIGEST_LEN + 1);
     94    if (RT_SUCCESS(rc))
     95    {
     96        rc = RTSha1ToString(auchDig, pszDigest, RTSHA1_DIGEST_LEN + 1);
     97        if (RT_SUCCESS(rc))
     98            *ppszDigest = pszDigest;
     99        else
     100            RTStrFree(pszDigest);
     101    }
    96102
    97103    return rc;
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