VirtualBox

Changeset 59609 in vbox


Ignore:
Timestamp:
Feb 8, 2016 8:56:14 PM (9 years ago)
Author:
vboxsync
Message:

VMDK.cpp: Corrected incorrect free. Drop const on temporary strings which needs freeing. Forgot a free in an out-of-memory path. Critiqued vmdkAllocGrainDirectory.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Storage/VMDK.cpp

    r59455 r59609  
    10221022    int rc = VINF_SUCCESS;
    10231023    size_t cbGD = pExtent->cGDEntries * sizeof(uint32_t);
     1024    /** @todo r=bird: This code is unnecessarily confusing pointer states with
     1025     *        (1) unnecessary initialization of locals, (2) unnecesarily wide
     1026     *        scoping of variables, (3) instance on goto code structure.  Also,
     1027     *        having two initialized variables on one line decreases readability. */
    10241028    uint32_t *pGD = NULL, *pRGD = NULL;
    10251029
     
    13651369}
    13661370
     1371/**
     1372 * @param   ppszUnquoted    Where to store the return value, use RTMemTmpFree to
     1373 *                          free.
     1374 */
    13671375static int vmdkStringUnquote(PVMDKIMAGE pImage, const char *pszStr,
    13681376                             char **ppszUnquoted, char **ppszNext)
     
    15681576}
    15691577
     1578/**
     1579 * @param   ppszValue       Where to store the return value, use RTMemTmpFree to
     1580 *                          free.
     1581 */
    15701582static int vmdkDescBaseGetStr(PVMDKIMAGE pImage, PVMDKDESCRIPTOR pDescriptor,
    1571                               const char *pszKey, const char **ppszValue)
     1583                              const char *pszKey, char **ppszValue)
    15721584{
    15731585    const char *pszValue;
     
    17011713}
    17021714
     1715/**
     1716 * @param   ppszValue       Where to store the return value, use RTMemTmpFree to
     1717 *                          free.
     1718 */
    17031719static int vmdkDescDDBGetStr(PVMDKIMAGE pImage, PVMDKDESCRIPTOR pDescriptor,
    1704                              const char *pszKey, const char **ppszValue)
     1720                             const char *pszKey, char **ppszValue)
    17051721{
    17061722    const char *pszValue;
     
    20492065
    20502066    /* Get image creation type and determine image flags. */
    2051     const char *pszCreateType = NULL;   /* initialized to make gcc shut up */
     2067    char *pszCreateType = NULL;   /* initialized to make gcc shut up */
    20522068    rc = vmdkDescBaseGetStr(pImage, &pImage->Descriptor, "createType",
    20532069                            &pszCreateType);
     
    20642080    else if (!strcmp(pszCreateType, "vmfs"))
    20652081        pImage->uImageFlags |= VD_IMAGE_FLAGS_FIXED | VD_VMDK_IMAGE_FLAGS_ESX;
    2066     RTStrFree((char *)(void *)pszCreateType);
     2082    RTMemTmpFree(pszCreateType);
    20672083
    20682084    /* Count the number of extent config entries. */
     
    36703686            char *pszBasename = (char *)RTMemTmpAlloc(cbTmp);
    36713687            if (!pszBasename)
     3688            {
     3689                RTStrFree(pszTmp);
    36723690                return VERR_NO_MEMORY;
     3691            }
    36733692            memcpy(pszBasename, pszTmp, cbTmp);
    36743693            RTStrFree(pszTmp);
     
    62436262    if (pImage)
    62446263    {
    6245         const char *pszCommentEncoded = NULL;
     6264        char *pszCommentEncoded = NULL;
    62466265        rc = vmdkDescDDBGetStr(pImage, &pImage->Descriptor,
    62476266                              "ddb.comment", &pszCommentEncoded);
     
    62596278            rc = VINF_SUCCESS;
    62606279        }
    6261         if (pszCommentEncoded)
    6262             RTStrFree((char *)(void *)pszCommentEncoded);
     6280        RTMemTmpFree(pszCommentEncoded);
    62636281    }
    62646282    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