[Mesa-dev] [PATCH] swrast: fix possible null dereference
Lars Hamre
chemecse at gmail.com
Wed Mar 9 18:21:09 UTC 2016
Fixes a possible null dereference.
NOTE: this is my first time contributing, please let me know if I
should be doing anything differently, thanks!
Signed-off-by: Lars Hamre <chemecse at gmail.com>
---
src/mesa/swrast/s_triangle.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index 876a74b..9225974 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -781,7 +781,7 @@ fast_persp_span(struct gl_context *ctx, SWspan *span,
}
break;
}
-
+
assert(span->arrayMask & SPAN_RGBA);
_swrast_write_rgba_span(ctx, span);
@@ -1063,8 +1063,8 @@ _swrast_choose_triangle( struct gl_context *ctx )
swImg = swrast_texture_image_const(texImg);
format = texImg ? texImg->TexFormat : MESA_FORMAT_NONE;
- minFilter = texObj2D ? samp->MinFilter : GL_NONE;
- magFilter = texObj2D ? samp->MagFilter : GL_NONE;
+ minFilter = (texObj2D && samp) ? samp->MinFilter : GL_NONE;
+ magFilter = (texObj2D && samp) ? samp->MagFilter : GL_NONE;
envMode = ctx->Texture.Unit[0].EnvMode;
/* First see if we can use an optimized 2-D texture function */
@@ -1073,6 +1073,7 @@ _swrast_choose_triangle( struct gl_context *ctx )
&& !ctx->ATIFragmentShader._Enabled
&& ctx->Texture._MaxEnabledTexImageUnit == 0
&& ctx->Texture.Unit[0]._Current->Target == GL_TEXTURE_2D
+ && samp
&& samp->WrapS == GL_REPEAT
&& samp->WrapT == GL_REPEAT
&& texObj2D->_Swizzle == SWIZZLE_NOOP
--
2.5.0
More information about the mesa-dev
mailing list