[Mesa-dev] [PATCH] i965: Avoid segfault in gen6_upload_state

Carl Worth cworth at cworth.org
Tue Feb 19 16:27:16 PST 2013


This fixes a bug introduced in commit 258453716f001eab1288d99765213 and
triggered whenever "rb" is NULL.

Fixes bug #59445:

	[SNB/IVB/HSW Bisected]Oglc draw-buffers2(advanced.blending.none) segfault
	https://bugs.freedesktop.org/show_bug.cgi?id=59445
---

I don't know under what conditions "rb" might be NULL, but it's clear that
it's possible and expected as there is earlier code in this function that
checks it, (and sets rb_type specifically in that case). So if someone could
help me write a more descriptive commit message, that would be great.

Also, I notice that similar code in brw_cc.c uses a different condition here:

       if (ctx->DrawBuffer->Visual.alphaBits == 0) {

So an alternate fix could be to switch to something like that. Please let me
know if one version or the other is cleaner, (and both could be made to
match).

 src/mesa/drivers/dri/i965/gen6_cc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/gen6_cc.c b/src/mesa/drivers/dri/i965/gen6_cc.c
index d32f636..7ac5d5f 100644
--- a/src/mesa/drivers/dri/i965/gen6_cc.c
+++ b/src/mesa/drivers/dri/i965/gen6_cc.c
@@ -126,7 +126,7 @@ gen6_upload_blend_state(struct brw_context *brw)
           * not read the alpha channel, but will instead use the correct
           * implicit value for alpha.
           */
-         if (!_mesa_base_format_has_channel(rb->_BaseFormat, GL_TEXTURE_ALPHA_TYPE))
+         if (rb && !_mesa_base_format_has_channel(rb->_BaseFormat, GL_TEXTURE_ALPHA_TYPE))
          {
             srcRGB = brw_fix_xRGB_alpha(srcRGB);
             srcA = brw_fix_xRGB_alpha(srcA);
-- 
1.7.10.4



More information about the mesa-dev mailing list