From 3bd460d39a1cae0106d26b033e7b4dfecb40c164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Wed, 6 Sep 2017 16:20:35 -0700 Subject: [PATCH] Fail to create static vertex buffer when VertexDecl is incorrect. --- src/bgfx_p.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/bgfx_p.h b/src/bgfx_p.h index b7c77b281..dc76ea02f 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -2478,7 +2478,13 @@ namespace bgfx BGFX_API_FUNC(VertexBufferHandle createVertexBuffer(const Memory* _mem, const VertexDecl& _decl, uint16_t _flags) ) { - VertexBufferHandle handle = { m_vertexBufferHandle.alloc() }; + VertexBufferHandle handle = BGFX_INVALID_HANDLE; + + BX_WARN(0 != _decl.m_stride, "VertexDecl stride is 0."); + if (0 != _decl.m_stride) + { + handle.idx = m_vertexBufferHandle.alloc(); + } BX_WARN(isValid(handle), "Failed to allocate vertex buffer handle."); if (isValid(handle) )