VirtualBox

Changeset 24372 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Nov 5, 2009 9:41:42 AM (15 years ago)
Author:
vboxsync
Message:

VBoxGuestR3LibMisc: Better memory handling.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibMisc.cpp

    r24332 r24372  
    242242     * Try get the *installed* version first.
    243243     */
    244     int rc = VINF_SUCCESS;
    245244    HKEY hKey;
    246245    LONG r;
     
    270269
    271270    /* Did we get something worth looking at? */
     271    int rc;
    272272    if (r == ERROR_SUCCESS)
    273273    {
     
    284284        DWORD dwType;
    285285        DWORD dwSize = 32;
     286        char *pszTmp;
    286287        if (ppszVer)
    287288        {
    288             char *pszVer = (char*)RTMemAlloc(dwSize);
    289             if (pszVer)
     289            pszTmp = (char*)RTMemAlloc(dwSize);
     290            if (pszTmp)
    290291            {
    291                 if (ERROR_SUCCESS == RegQueryValueEx(hKey, "Version", NULL, &dwType, (BYTE*)(LPCTSTR)pszVer, &dwSize))
    292                     *ppszVer = pszVer;
     292                r = RegQueryValueEx(hKey, "Version", NULL, &dwType, (BYTE*)(LPCTSTR)pszTmp, &dwSize);
     293                if (r == ERROR_SUCCESS)
     294                    rc = RTStrDupEx(ppszVer, pszTmp);
     295                else
     296                    rc = RTErrConvertFromNtStatus(r);
     297                RTMemFree(pszTmp);
    293298            }
     299            else
     300                rc = VERR_NO_MEMORY;
    294301        }
    295302        /* Revision. */
     
    297304        {
    298305            dwSize = 32; /* Reset */
    299             char *pszRev = (char*)RTMemAlloc(dwSize);
    300             if (pszRev)
     306            pszTmp = (char*)RTMemAlloc(dwSize);
     307            if (pszTmp)
    301308            {
    302                 if (ERROR_SUCCESS == RegQueryValueEx(hKey, "Revision", NULL, &dwType, (BYTE*)(LPCTSTR)pszRev, &dwSize))
    303                     *ppszRev = pszRev;
     309                r = RegQueryValueEx(hKey, "Revision", NULL, &dwType, (BYTE*)(LPCTSTR)pszTmp, &dwSize);
     310                if (r == ERROR_SUCCESS)
     311                    rc = RTStrDupEx(ppszRev, pszTmp);
     312                else
     313                    rc = RTErrConvertFromNtStatus(r);
     314                RTMemFree(pszTmp);
    304315            }
     316            else
     317                rc = VERR_NO_MEMORY;
    305318        }
    306319    }
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