VirtualBox

Ignore:
Timestamp:
Feb 23, 2015 11:24:25 AM (10 years ago)
Author:
vboxsync
Message:

ExtPacks/VNC: fixed a possible crash when the client connects during VM restore (thanks Yonathan Randolph)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ExtPacks/VNC/VBoxVNC.cpp

    r51231 r54380  
    8080        if (mCursor)
    8181            rfbFreeCursor(mCursor);
    82         memset(szVNCPassword, '\0', sizeof(szVNCPassword));
     82        RT_ZERO(szVNCPassword);
    8383        if (mVNCServer)
    8484            rfbScreenCleanup(mVNCServer);
     
    261261    LogFlowFunc(("enter\n"));
    262262
    263     // query server for the framebuffer
     263    // At this point, VRDECallbackFramebufferQuery will not succeed.
     264    // Initialize VNC with 640x480 and wait for VRDEResize to get actual size.
     265    int dummyWidth = 640, dummyHeight = 480;
     266
     267    rfbScreenInfoPtr vncServer = rfbGetScreen(0, NULL, dummyWidth, dummyHeight, 8, 3, VNC_SIZEOFRGBA);
     268    instance->mVNCServer = vncServer;
     269
    264270    VRDEFRAMEBUFFERINFO info;
    265     int rc = instance->mCallbacks->VRDECallbackFramebufferQuery(instance->mCallback, 0, &info);
    266 
    267     rfbScreenInfoPtr vncServer = rfbGetScreen(0, NULL, info.cWidth, info.cHeight, 8, 3, VNC_SIZEOFRGBA);
    268     instance->mVNCServer = vncServer;
     271    RT_ZERO(info);
     272    info.cWidth = dummyWidth, info.cHeight = dummyHeight;
     273    info.cBitsPerPixel = 24;
     274    info.pu8Bits = NULL;
     275    unsigned char *FrameBuffer = (unsigned char *)RTMemAlloc(info.cWidth * info.cHeight * VNC_SIZEOFRGBA); // RGBA
     276    rfbNewFramebuffer(instance->mVNCServer, (char *)FrameBuffer, info.cWidth, info.cHeight, 8, 3, VNC_SIZEOFRGBA);
     277    instance->mFrameBuffer = FrameBuffer;
     278    instance->mScreenBuffer = (unsigned char *)info.pu8Bits;
     279    instance->FrameInfo = info;
     280
    269281    vncServer->serverFormat.redShift = 16;
    270282    vncServer->serverFormat.greenShift = 8;
     
    278290    char szAddress[VNC_ADDRESSSIZE + 1] = {0};
    279291    uint32_t cbOut = 0;
    280     rc = instance->mCallbacks->VRDECallbackProperty(instance->mCallback,
     292    int rc = instance->mCallbacks->VRDECallbackProperty(instance->mCallback,
    281293                                                    VRDE_QP_NETWORK_ADDRESS,
    282294                                                    &szAddress, sizeof(szAddress), &cbOut);
     
    716728    VNCServerImpl *instance = (VNCServerImpl *)hServer;
    717729    VRDEFRAMEBUFFERINFO info;
    718     int rc = instance->mCallbacks->VRDECallbackFramebufferQuery(instance->mCallback, 0, &info);
    719     if (!RT_SUCCESS(rc))
    720     {
     730    bool fAvail = instance->mCallbacks->VRDECallbackFramebufferQuery(instance->mCallback, 0, &info);
     731    if (!fAvail)
    721732        return;
    722     }
    723733
    724734    LogRel(("VNCServerImpl::VRDEResize to %dx%dx%dbpp\n", info.cWidth, info.cHeight, info.cBitsPerPixel));
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