[Mesa-dev] [PATCH 10/12] gallium/hud: prevent a crash if the recording context is inactive

Marek Olšák maraeo at gmail.com
Tue Nov 21 17:46:10 UTC 2017


From: Marek Olšák <marek.olsak at amd.com>

---
 src/gallium/auxiliary/hud/hud_context.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c
index e3fcad2..7502416 100644
--- a/src/gallium/auxiliary/hud/hud_context.c
+++ b/src/gallium/auxiliary/hud/hud_context.c
@@ -67,21 +67,24 @@ signal_visible_handler(int sig, siginfo_t *siginfo, void *context)
 
 static void
 hud_draw_colored_prims(struct hud_context *hud, unsigned prim,
                        float *buffer, unsigned num_vertices,
                        float r, float g, float b, float a,
                        int xoffset, int yoffset, float yscale)
 {
    struct cso_context *cso = hud->cso;
    unsigned size = num_vertices * hud->color_prims.vbuf.stride;
 
-   assert(size <= hud->color_prims.buffer_size);
+   /* If a recording context is inactive, don't draw anything. */
+   if (size > hud->color_prims.buffer_size)
+      return;
+
    memcpy(hud->color_prims.vertices, buffer, size);
 
    hud->constants.color[0] = r;
    hud->constants.color[1] = g;
    hud->constants.color[2] = b;
    hud->constants.color[3] = a;
    hud->constants.translate[0] = (float) xoffset;
    hud->constants.translate[1] = (float) yoffset;
    hud->constants.scale[0] = 1;
    hud->constants.scale[1] = yscale;
-- 
2.7.4



More information about the mesa-dev mailing list