swrast: Avoid aliasing violation.
authorMatt Turner <mattst88@gmail.com>
Thu, 26 May 2016 22:52:33 +0000 (15:52 -0700)
committerMatt Turner <mattst88@gmail.com>
Tue, 26 Jul 2016 19:12:27 +0000 (12:12 -0700)
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/swrast/s_masking.c

index c95587b204ce82cf4f8e1865cca23784057e3c54..c10bf1ac2516e030ae66f937fde57865f0011929 100644 (file)
@@ -56,8 +56,8 @@ _swrast_mask_rgba_span(struct gl_context *ctx, struct gl_renderbuffer *rb,
     * Note that we're not using span->array->mask[] here.  We could...
     */
    if (span->array->ChanType == GL_UNSIGNED_BYTE) {
-      /* treat 4xGLubyte as 1xGLuint */
-      const GLuint srcMask = *((GLuint *) ctx->Color.ColorMask[buf]);
+      GLuint srcMask;
+      memcpy(&srcMask, ctx->Color.ColorMask[buf], sizeof(srcMask));
       const GLuint dstMask = ~srcMask;
       const GLuint *dst = (const GLuint *) rbPixels;
       GLuint *src = (GLuint *) span->array->rgba8;