[Mesa-dev] [PATCH 06/34] draw/gs: fix allocation of buffer for GS output vertices

Paul Berry stereotype441 at gmail.com
Sun Jul 28 23:03:32 PDT 2013


From: Bryan Cain <bryancain3 at gmail.com>

Before, it accounted for the size of the vertices but not the other fields
in the vertex_header struct, which caused memory corruption.
---
 src/gallium/auxiliary/draw/draw_gs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/draw/draw_gs.c b/src/gallium/auxiliary/draw/draw_gs.c
index cd63e2b..78727c6 100644
--- a/src/gallium/auxiliary/draw/draw_gs.c
+++ b/src/gallium/auxiliary/draw/draw_gs.c
@@ -560,7 +560,8 @@ int draw_geometry_shader_run(struct draw_geometry_shader *shader,
    /* we allocate exactly one extra vertex per primitive to allow the GS to emit
     * overflown vertices into some area where they won't harm anyone */
    output_verts->verts =
-      (struct vertex_header *)MALLOC(output_verts->vertex_size *
+      (struct vertex_header *)MALLOC(sizeof(struct vertex_header) +
+                                     output_verts->vertex_size *
                                      max_out_prims *
                                      shader->primitive_boundary);
 
-- 
1.8.3.4



More information about the mesa-dev mailing list