From d9fa69c28870fafb10b3df1720eec0451ab18b47 Mon Sep 17 00:00:00 2001 From: Luke Benstead Date: Thu, 6 Sep 2018 19:46:04 +0100 Subject: [PATCH] Fix invalid memory access bug --- GL/draw.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/GL/draw.c b/GL/draw.c index 0828f04..aabfb8f 100644 --- a/GL/draw.c +++ b/GL/draw.c @@ -780,6 +780,7 @@ static void submitVertices(GLenum mode, GLsizei first, GLsizei count, GLenum typ /* Make room in the list buffer */ GLsizei spaceNeeded = (mode == GL_POLYGON || mode == GL_TRIANGLE_FAN) ? ((count - 2) * 3) : count; ClipVertex* start = aligned_vector_extend(&activeList->vector, spaceNeeded + 1); + uint32_t startOffset = start - (ClipVertex*) activeList->vector.data; /* Store a pointer to the header for later */ PVRHeader* header = (PVRHeader*) start++; @@ -828,11 +829,15 @@ static void submitVertices(GLenum mode, GLsizei first, GLsizei count, GLenum typ fprintf(stderr, "%x\n", *((uint32_t*)v)); } } - */ +#endif + } profiler_checkpoint("clip"); + /* Clipping may have realloc'd so reset the start pointer */ + start = ((ClipVertex*) activeList->vector.data) + startOffset; + divide(start, spaceNeeded); profiler_checkpoint("divide");