VirtualBox

Changeset 98783 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Feb 28, 2023 3:00:59 PM (21 months ago)
Author:
vboxsync
Message:

Devices/Graphics: correctly load a saved state which has no surfaces or contexts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-dx-savedstate.cpp

    r98103 r98783  
    222222     * Surfaces
    223223     */
    224     p3dState->papSurfaces = (PVMSVGA3DSURFACE *)RTMemAlloc(p3dState->cSurfaces * sizeof(PVMSVGA3DSURFACE));
    225     AssertReturn(p3dState->papSurfaces, VERR_NO_MEMORY);
    226     for (uint32_t i = 0; i < p3dState->cSurfaces; ++i)
    227     {
    228         p3dState->papSurfaces[i] = (PVMSVGA3DSURFACE)RTMemAllocZ(sizeof(VMSVGA3DSURFACE));
    229         AssertPtrReturn(p3dState->papSurfaces[i], VERR_NO_MEMORY);
    230         p3dState->papSurfaces[i]->id = SVGA3D_INVALID_ID;
    231     }
    232 
    233     for (uint32_t i = 0; i < p3dState->cSurfaces; ++i)
    234     {
    235         rc = vmsvga3dDXLoadSurface(pHlp, pThisCC, pSSM);
    236         AssertRCReturn(rc, rc);
    237     }
     224    if (p3dState->cSurfaces)
     225    {
     226        p3dState->papSurfaces = (PVMSVGA3DSURFACE *)RTMemAlloc(p3dState->cSurfaces * sizeof(PVMSVGA3DSURFACE));
     227        AssertReturn(p3dState->papSurfaces, VERR_NO_MEMORY);
     228        for (uint32_t i = 0; i < p3dState->cSurfaces; ++i)
     229        {
     230            p3dState->papSurfaces[i] = (PVMSVGA3DSURFACE)RTMemAllocZ(sizeof(VMSVGA3DSURFACE));
     231            AssertPtrReturn(p3dState->papSurfaces[i], VERR_NO_MEMORY);
     232            p3dState->papSurfaces[i]->id = SVGA3D_INVALID_ID;
     233        }
     234
     235        for (uint32_t i = 0; i < p3dState->cSurfaces; ++i)
     236        {
     237            rc = vmsvga3dDXLoadSurface(pHlp, pThisCC, pSSM);
     238            AssertRCReturn(rc, rc);
     239        }
     240    }
     241    else
     242        p3dState->papSurfaces = NULL;
    238243
    239244    /*
    240245     * DX contexts
    241246     */
    242     p3dState->papDXContexts = (PVMSVGA3DDXCONTEXT *)RTMemAlloc(p3dState->cDXContexts * sizeof(PVMSVGA3DDXCONTEXT));
    243     AssertReturn(p3dState->papDXContexts, VERR_NO_MEMORY);
    244     for (uint32_t i = 0; i < p3dState->cDXContexts; ++i)
    245     {
    246         p3dState->papDXContexts[i] = (PVMSVGA3DDXCONTEXT)RTMemAllocZ(sizeof(VMSVGA3DDXCONTEXT));
    247         AssertPtrReturn(p3dState->papDXContexts[i], VERR_NO_MEMORY);
    248         p3dState->papDXContexts[i]->cid = SVGA3D_INVALID_ID;
    249     }
    250 
    251     for (uint32_t i = 0; i < p3dState->cDXContexts; ++i)
    252     {
    253         rc = vmsvga3dDXLoadContext(pHlp, pThisCC, pSSM);
    254         AssertRCReturn(rc, rc);
    255     }
     247    if (p3dState->cDXContexts)
     248    {
     249        p3dState->papDXContexts = (PVMSVGA3DDXCONTEXT *)RTMemAlloc(p3dState->cDXContexts * sizeof(PVMSVGA3DDXCONTEXT));
     250        AssertReturn(p3dState->papDXContexts, VERR_NO_MEMORY);
     251        for (uint32_t i = 0; i < p3dState->cDXContexts; ++i)
     252        {
     253            p3dState->papDXContexts[i] = (PVMSVGA3DDXCONTEXT)RTMemAllocZ(sizeof(VMSVGA3DDXCONTEXT));
     254            AssertPtrReturn(p3dState->papDXContexts[i], VERR_NO_MEMORY);
     255            p3dState->papDXContexts[i]->cid = SVGA3D_INVALID_ID;
     256        }
     257
     258        for (uint32_t i = 0; i < p3dState->cDXContexts; ++i)
     259        {
     260            rc = vmsvga3dDXLoadContext(pHlp, pThisCC, pSSM);
     261            AssertRCReturn(rc, rc);
     262        }
     263    }
     264    else
     265        p3dState->papDXContexts = NULL;
    256266
    257267    if (pSvgaR3State->idDXContextCurrent != SVGA_ID_INVALID)
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