From 73e51113358375a2f4a2e064a73e88962a337a1b Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sat, 14 Jan 2017 01:20:07 -0400 Subject: [PATCH] Potentially fix a crash in love.window.setMode. --HG-- branch : minor --- src/modules/graphics/Graphics.h | 14 ++++++++++---- src/modules/graphics/StreamBuffer.cpp | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/modules/graphics/Graphics.h b/src/modules/graphics/Graphics.h index 35787e855..0412fe04f 100644 --- a/src/modules/graphics/Graphics.h +++ b/src/modules/graphics/Graphics.h @@ -755,13 +755,19 @@ protected: struct StreamBufferState { StreamBuffer *vb[2]; - StreamBuffer *indexBuffer; - vertex::PrimitiveMode primitiveMode; + StreamBuffer *indexBuffer = nullptr; + vertex::PrimitiveMode primitiveMode = vertex::PrimitiveMode::TRIANGLES; vertex::CommonFormat formats[2]; StrongRef texture; ptrdiff_t textureHandle = 0; - int vertexCount; - int indexCount; + int vertexCount = 0; + int indexCount = 0; + + StreamBufferState() + { + vb[0] = vb[1] = nullptr; + formats[0] = formats[1] = vertex::CommonFormat::NONE; + } }; void restoreState(const DisplayState &s); diff --git a/src/modules/graphics/StreamBuffer.cpp b/src/modules/graphics/StreamBuffer.cpp index 8fc09fd79..7f13ddc26 100644 --- a/src/modules/graphics/StreamBuffer.cpp +++ b/src/modules/graphics/StreamBuffer.cpp @@ -37,7 +37,7 @@ StreamBuffer::StreamBuffer(Mode mode, size_t size) StreamBuffer::~StreamBuffer() { - delete[] data; + delete[] data; } void *StreamBuffer::getData() const