From 2cebe3ef34077293949132a5779941d9e1b3529e Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 7 Feb 2007 05:54:13 +0000 Subject: [PATCH] fix crash with empty models --- stepmania/src/RageDisplay_D3D.cpp | 4 ++-- stepmania/src/RageDisplay_OGL.cpp | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/stepmania/src/RageDisplay_D3D.cpp b/stepmania/src/RageDisplay_D3D.cpp index 33a6c0abd1..4e5a700efa 100644 --- a/stepmania/src/RageDisplay_D3D.cpp +++ b/stepmania/src/RageDisplay_D3D.cpp @@ -852,8 +852,8 @@ class RageCompiledGeometrySWD3D : public RageCompiledGeometry public: void Allocate( const vector &vMeshes ) { - m_vVertex.resize( GetTotalVertices() ); - m_vTriangles.resize( GetTotalTriangles() ); + m_vVertex.resize( max(1u, GetTotalVertices()) ); + m_vTriangles.resize( max(1u, GetTotalTriangles()) ); } void Change( const vector &vMeshes ) { diff --git a/stepmania/src/RageDisplay_OGL.cpp b/stepmania/src/RageDisplay_OGL.cpp index 305dea8178..1ee16f80c1 100644 --- a/stepmania/src/RageDisplay_OGL.cpp +++ b/stepmania/src/RageDisplay_OGL.cpp @@ -756,11 +756,12 @@ public: void Allocate( const vector &vMeshes ) { - m_vPosition.resize( GetTotalVertices() ); - m_vTexture.resize( GetTotalVertices() ); - m_vNormal.resize( GetTotalVertices() ); - m_vTexMatrixScale.resize( GetTotalVertices() ); - m_vTriangles.resize( GetTotalTriangles() ); + /* Always allocate at least 1 entry, so &x[0] is valid. */ + m_vPosition.resize( max(1u, GetTotalVertices()) ); + m_vTexture.resize( max(1u, GetTotalVertices()) ); + m_vNormal.resize( max(1u, GetTotalVertices()) ); + m_vTexMatrixScale.resize( max(1u, GetTotalVertices()) ); + m_vTriangles.resize( max(1u, GetTotalTriangles()) ); } void Change( const vector &vMeshes ) {