Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8vertexbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,11 @@ void DynamicVBAccessClass::Allocate_DX8_Dynamic_Buffer()
_DynamicDX8VertexBufferSize,
(DX8VertexBufferClass::UsageType)usage));
_DynamicDX8VertexBufferOffset=0;

// If allocation failed, leave VertexBuffer as nullptr and return early
if (!_DynamicDX8VertexBuffer) {
return;
}
}

// Any room at the end of the buffer?
Expand Down Expand Up @@ -839,6 +844,12 @@ DynamicVBAccessClass::WriteLockClass::WriteLockClass(DynamicVBAccessClass* dynam
WWASSERT(_DynamicDX8VertexBuffer);
// WWASSERT(!_DynamicDX8VertexBuffer->Engine_Refs());

// Guard against a failed vertex buffer allocation
if (!DynamicVBAccess->VertexBuffer) {
Vertices=nullptr;
break;
}

DX8_Assert();
// Lock with discard contents if the buffer offset is zero
DX8_ErrorCode(static_cast<DX8VertexBufferClass*>(DynamicVBAccess->VertexBuffer)->Get_DX8_Vertex_Buffer()->Lock(
Expand Down Expand Up @@ -870,6 +881,10 @@ DynamicVBAccessClass::WriteLockClass::~WriteLockClass()
WWASSERT(!dx8_lock);
WWDEBUG_SAY(("DynamicVertexBuffer->Unlock()"));
#endif
// Guard against a failed vertex buffer allocation
if (!DynamicVBAccess->VertexBuffer) {
break;
}
DX8_Assert();
DX8_ErrorCode(static_cast<DX8VertexBufferClass*>(DynamicVBAccess->VertexBuffer)->Get_DX8_Vertex_Buffer()->Unlock());
break;
Expand Down
15 changes: 15 additions & 0 deletions GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8vertexbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,11 @@ void DynamicVBAccessClass::Allocate_DX8_Dynamic_Buffer()
_DynamicDX8VertexBufferSize,
(DX8VertexBufferClass::UsageType)usage));
_DynamicDX8VertexBufferOffset=0;

// If allocation failed, leave VertexBuffer as nullptr and return early
if (!_DynamicDX8VertexBuffer) {
return;
}
}

// Any room at the end of the buffer?
Expand Down Expand Up @@ -852,6 +857,12 @@ DynamicVBAccessClass::WriteLockClass::WriteLockClass(DynamicVBAccessClass* dynam
WWASSERT(_DynamicDX8VertexBuffer);
// WWASSERT(!_DynamicDX8VertexBuffer->Engine_Refs());

// Guard against a failed vertex buffer allocation
if (!DynamicVBAccess->VertexBuffer) {
Vertices=nullptr;
break;
}

DX8_Assert();
// Lock with discard contents if the buffer offset is zero
DX8_ErrorCode(static_cast<DX8VertexBufferClass*>(DynamicVBAccess->VertexBuffer)->Get_DX8_Vertex_Buffer()->Lock(
Expand Down Expand Up @@ -884,6 +895,10 @@ DynamicVBAccessClass::WriteLockClass::~WriteLockClass()
WWDEBUG_SAY(("DynamicVertexBuffer->Unlock()"));
*/
#endif
// Guard against a failed vertex buffer allocation
if (!DynamicVBAccess->VertexBuffer) {
break;
}
DX8_Assert();
DX8_ErrorCode(static_cast<DX8VertexBufferClass*>(DynamicVBAccess->VertexBuffer)->Get_DX8_Vertex_Buffer()->Unlock());
break;
Expand Down
Loading