VirtualBox

Ignore:
Timestamp:
Apr 27, 2010 2:42:14 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
60751
Message:

Guest Control: Bugfixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/GuestImpl.cpp

    r28816 r28833  
    582582        pCBData->u32Flags = pData->u32Flags;
    583583
    584         /* Allocate data buffer and copy it */
    585         if (pData->cbData && pData->pvData)
    586         {
     584        /* Make sure we really got something! */
     585        if (   pData->cbData
     586            && pData->pvData)
     587        {
     588            /* Allocate data buffer and copy it */
    587589            pCBData->pvData = RTMemAlloc(pData->cbData);
    588590            AssertReturn(pCBData->pvData, VERR_NO_MEMORY);
    589591            memcpy(pCBData->pvData, pData->pvData, pData->cbData);
    590592            pCBData->cbData = pData->cbData;
     593        }
     594        else
     595        {
     596            pCBData->pvData = NULL;
     597            pCBData->cbData = 0;
    591598        }
    592599        ASMAtomicWriteBool(&it->bCalled, true);
     
    10391046                } while (!it->bCalled);
    10401047   
    1041                 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    1042    
    1043                 /* Did we get some output? */
    1044                 pData = (HOSTEXECOUTCALLBACKDATA*)it->pvData;
    1045                 Assert(it->cbData == sizeof(HOSTEXECOUTCALLBACKDATA));
    1046                 AssertPtr(pData);
    1047    
    1048                 if (   it->bCalled
    1049                     && pData->cbData
    1050                     && pData->pvData)
     1048                if (it->bCalled)
    10511049                {
    1052                     /* Do we need to resize the array? */
    1053                     if (pData->cbData > cbData)
    1054                         outputData.resize(pData->cbData);
    1055    
    1056                     /* Fill output in supplied out buffer. */
    1057                     memcpy(outputData.raw(), pData->pvData, pData->cbData);
    1058                     outputData.resize(pData->cbData); /* Shrink to fit actual buffer size. */
     1050                    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     1051       
     1052                    /* Did we get some output? */
     1053                    pData = (HOSTEXECOUTCALLBACKDATA*)it->pvData;
     1054                    Assert(it->cbData == sizeof(HOSTEXECOUTCALLBACKDATA));
     1055                    AssertPtr(pData);
     1056       
     1057                    if (pData->cbData)
     1058                    {
     1059                        /* Do we need to resize the array? */
     1060                        if (pData->cbData > cbData)
     1061                            outputData.resize(pData->cbData);
     1062       
     1063                        /* Fill output in supplied out buffer. */
     1064                        memcpy(outputData.raw(), pData->pvData, pData->cbData);
     1065                        outputData.resize(pData->cbData); /* Shrink to fit actual buffer size. */
     1066                    }
     1067                    else
     1068                        vrc = VERR_NO_DATA; /* This is not an error we want to report to COM. */
    10591069                }
    1060                 else
    1061                     vrc = VERR_NO_DATA; /* This is not an error we want to report to COM. */
     1070                else /* If callback not called within time ... well, that's a timeout! */
     1071                    vrc = VERR_TIMEOUT;
     1072
     1073                if (RT_FAILURE(vrc))
     1074                {
     1075                    if (vrc == VERR_NO_DATA)
     1076                    {
     1077                        /* This is not an error we want to report to COM. */
     1078                    }
     1079                    else if (vrc == VERR_TIMEOUT)
     1080                    {
     1081                        rc = setError(VBOX_E_IPRT_ERROR,
     1082                                      tr("The guest did not output within time (%ums)"), aTimeoutMS);
     1083                    }
     1084                    else
     1085                    {
     1086                        rc = setError(E_UNEXPECTED,
     1087                                      tr("The service call failed with error %Rrc"), vrc);
     1088                    }
     1089                }
    10621090            }
    10631091            else
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette