VirtualBox

Changeset 54996 in vbox


Ignore:
Timestamp:
Mar 27, 2015 7:27:55 PM (10 years ago)
Author:
vboxsync
Message:

DrvAudioVRDE.cpp: Fixed stupid use after free issue in the destructor introduced by a previous employee (the original code had this down right). Restore other mandatory PDM driver bits that seems to have gotten lost in the copying+rewrite process.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/DrvAudioVRDE.cpp

    r54493 r54996  
    1515 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
    1616 */
     17
     18
     19/*******************************************************************************
     20*   Header Files                                                               *
     21*******************************************************************************/
    1722#include "DrvAudioVRDE.h"
    1823#include "ConsoleImpl.h"
     
    3439#include <VBox/err.h>
    3540
    36 #ifdef LOG_GROUP
    37  #undef LOG_GROUP
    38 #endif
     41#undef LOG_GROUP
    3942#define LOG_GROUP LOG_GROUP_DEV_AUDIO
    4043#include <VBox/log.h>
    4144
     45
     46/*******************************************************************************
     47*   Structures and Typedefs                                                    *
     48*******************************************************************************/
    4249/**
    4350 * Audio VRDE driver instance data.
     
    7784} VRDESTREAMOUT, *PVRDESTREAMOUT;
    7885
     86
     87
    7988static DECLCALLBACK(int) drvAudioVRDEInit(PPDMIHOSTAUDIO pInterface)
    8089{
     
    133142
    134143/**
     144 * <Missing brief description>
     145 *
    135146 * Transfers audio input formerly sent by a connected RDP client / VRDE backend
    136147 * (using the onVRDEInputXXX methods) over to the VRDE host (VM). The audio device
     
    182193
    183194/**
     195 * Transfers VM audio output to remote client.
     196 *
    184197 * Transfers VM audio output over to the VRDE instance for playing remotely
    185198 * on the client.
     
    474487DECLCALLBACK(int) AudioVRDE::drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)
    475488{
     489    PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
     490    PDRVAUDIOVRDE pThis = PDMINS_2_DATA(pDrvIns, PDRVAUDIOVRDE);
    476491    AssertPtrReturn(pDrvIns, VERR_INVALID_POINTER);
    477492    AssertPtrReturn(pCfg, VERR_INVALID_POINTER);
    478 
    479     PDRVAUDIOVRDE pThis = PDMINS_2_DATA(pDrvIns, PDRVAUDIOVRDE);
    480493
    481494    LogRel(("Audio: Initializing VRDE driver\n"));
     
    503516    void *pvUser;
    504517    int rc = CFGMR3QueryPtr(pCfg, "ObjectVRDPServer", &pvUser);
    505     if (RT_FAILURE(rc))
    506     {
    507         AssertMsgFailed(("Confguration error: No/bad \"ObjectVRDPServer\" value, rc=%Rrc\n", rc));
    508         return rc;
    509     }
     518    AssertMsgRCReturn(rc, ("Confguration error: No/bad \"ObjectVRDPServer\" value, rc=%Rrc\n", rc), rc);
    510519
    511520    /* CFGM tree saves the pointer to ConsoleVRDPServer in the Object node of AudioVRDE. */
     
    517526    pvUser = NULL;
    518527    rc = CFGMR3QueryPtr(pCfg, "Object", &pvUser);
    519     if (RT_FAILURE(rc))
    520     {
    521         AssertMsgFailed(("Confguration error: No/bad \"Object\" value, rc=%Rrc\n", rc));
    522         return rc;
    523     }
     528    AssertMsgRCReturn(rc, ("Confguration error: No/bad \"Object\" value, rc=%Rrc\n", rc), rc);
    524529
    525530    pThis->pAudioVRDE = (AudioVRDE *)pvUser;
     
    531536     */
    532537    pThis->pDrvAudio = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIAUDIOCONNECTOR);
    533     if (!pThis->pDrvAudio)
    534     {
    535         AssertMsgFailed(("Configuration error: No upper interface specified!\n"));
    536         return VERR_PDM_MISSING_INTERFACE_ABOVE;
    537     }
    538 
    539     return VINF_SUCCESS;
    540 }
    541 
     538    AssertMsgReturn(pThis->pDrvAudio, ("Configuration error: No upper interface specified!\n"), VERR_PDM_MISSING_INTERFACE_ABOVE);
     539
     540    return VINF_SUCCESS;
     541}
     542
     543
     544/**
     545 * @interface_method_impl{PDMDRVREG,pfnDestruct}
     546 */
    542547/* static */
    543548DECLCALLBACK(void) AudioVRDE::drvDestruct(PPDMDRVINS pDrvIns)
    544549{
     550    PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns);
     551    PDRVAUDIOVRDE pThis = PDMINS_2_DATA(pDrvIns, PDRVAUDIOVRDE);
    545552    LogFlowFuncEnter();
    546 }
     553
     554    /*
     555     * If the AudioVRDE object is still alive, we must clear it's reference to
     556     * us since we'll be invalid when we return from this method.
     557     */
     558    if (pThis->pAudioVRDE)
     559    {
     560        pThis->pAudioVRDE->mpDrv = NULL;
     561        pThis->pAudioVRDE = NULL;
     562    }
     563}
     564
    547565
    548566/**
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