From 2f3a6da295056e5b1cd0329e3c399ea4832b6343 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 5 Dec 2016 04:05:55 +0100 Subject: [PATCH] Fix buffer overrun --- src/gl/system/gl_swframebuffer.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gl/system/gl_swframebuffer.cpp b/src/gl/system/gl_swframebuffer.cpp index 421fe92781..6b3caa81ef 100644 --- a/src/gl/system/gl_swframebuffer.cpp +++ b/src/gl/system/gl_swframebuffer.cpp @@ -2316,7 +2316,11 @@ bool OpenGLSWFrameBuffer::OpenGLPal::Update() { buff[i] = ColorARGB(pal[i].a, pal[i - 1].r, pal[i - 1].g, pal[i - 1].b); } - BorderColor = ColorARGB(pal[i].a, pal[i - 1].r, pal[i - 1].g, pal[i - 1].b); + if (numEntries > 1) + { + i = numEntries - 1; + BorderColor = ColorARGB(pal[i].a, pal[i - 1].r, pal[i - 1].g, pal[i - 1].b); + } glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); GLint oldBinding = 0;