From 9df3f28a8bad8892edb114c49b5ed18e555488f9 Mon Sep 17 00:00:00 2001 From: Julien Isorce Date: Fri, 10 Mar 2017 17:16:07 +0000 Subject: [PATCH] gallium/hud: check NULL return from u_upload_alloc MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fixes the following segmentation fault: signal SIGSEGV: invalid address (fault address: 0x0) frame #0: 0x00007fffe718e117 radeonsi_dri.so hud_draw_background_quad hud_context.c:170 167 168 assert(hud->bg.num_vertices + 4 <= hud->bg.max_num_vertices); 169 -> 170 vertices[num++] = (float) x1; 171 vertices[num++] = (float) y1; 172 173 vertices[num++] = (float) x1; (lldb) bt * frame #0: 0x00007fffe718e117 radeonsi_dri.so`hud_draw_background_quad frame #1: 0x00007fffe718f458 radeonsi_dri.so`hud_draw frame #2: 0x00007fffe712967f radeonsi_dri.so`dri_flush Signed-off-by: Marek Olšák --- src/gallium/auxiliary/hud/hud_context.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c index c44f8c01a31..29ef9eee31c 100644 --- a/src/gallium/auxiliary/hud/hud_context.c +++ b/src/gallium/auxiliary/hud/hud_context.c @@ -581,6 +581,10 @@ hud_draw(struct hud_context *hud, struct pipe_resource *tex) hud->color_prims.buffer_size, 16, &hud->bg.vbuf.buffer_offset, &hud->bg.vbuf.buffer, (void**)&hud->bg.vertices); + if (!hud->bg.vertices) { + goto out; + } + pipe_resource_reference(&hud->whitelines.vbuf.buffer, hud->bg.vbuf.buffer); pipe_resource_reference(&hud->text.vbuf.buffer, hud->bg.vbuf.buffer); pipe_resource_reference(&hud->color_prims.vbuf.buffer, hud->bg.vbuf.buffer); @@ -690,6 +694,7 @@ hud_draw(struct hud_context *hud, struct pipe_resource *tex) hud_pane_draw_colored_objects(hud, pane); } +out: cso_restore_state(cso); cso_restore_constant_buffer_slot0(cso, PIPE_SHADER_VERTEX); -- 2.30.2